this is based on some dev.to articles here https://dev.to/diegocasmo/using-postgres-enum-type-in-rails-30mo and here https://dev.to/amplifr/postgres-enums-with-rails-4ld0 and the same guy's article here https://medium.com/@diegocasmo/using-postgres-enum-type-in-rails-799db99117ff
If you follow the advice above, you are advised to create a Rails schema migration for your Postgres backed schema by using CREATE TYPE xyz_setting AS ENUM directly on Postgres, and then use that to create your new field as an ENUM (a postgres enum)
Unfortunately, this approach has the downside of breaking the db/schema.rb file.
I think the problem is that the native Postgres types are not supported by the Rails core.
I can reproduce the behavior on Rails 5.17, 5.2.2.4, and 6.0.3
if I do...
class AddXyzToUsers < ActiveRecord::Migration[5.2]
def up
execute <<-DDL
CREATE TYPE xyz_setting AS ENUM (
'apple', 'bananna', 'cherry'
);
DDL
add_column :users, :xyz, :xyz_setting
end
def down
remove_column :users, :xyz
execute "DROP type xyz_setting;"
end
end
then my schema file is messed up, specifically, the schema users table doesn't get output whatseover, and instead in its place is this message
config.active_record.schema_format = :sqlin the environment configuration files?