Unfortunately, this approach has the downside of breaking the db/schema.rb file.
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
Could not dump table "users" because of following StandardError
Unknown type 'xyz_setting' for column 'xyz'
I think maybe there's a gem I found that fixes this.
Ah yes, this works as expected and leaves you with no more db/schema.rb file and instead a db/structure.sql file written in the native SQL Postgres commands instead of the Rails schema syntax.
Unfortunately, this approach has the downside of breaking the db/schema.rb file.
I can reproduce the behavior on Rails 5.17, 5.2.2.4, and 6.0.3
if I do...
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
Could not dump table "users" because of following StandardError
Unknown type 'xyz_setting' for column 'xyz'
I think maybe there's a gem I found that fixes this.
stackoverflow.com/questions/646689...
Did you try setting
config.active_record.schema_format = :sql
in the environment configuration files?Ah yes, this works as expected and leaves you with no more
db/schema.rb
file and instead adb/structure.sql
file written in the native SQL Postgres commands instead of the Rails schema syntax.github.com/jasonfb/R5244EnumIssueTest