diff --git a/lib/active_record/postgres_enum/command_recorder.rb b/lib/active_record/postgres_enum/command_recorder.rb index 37518cf..2e7fbf8 100644 --- a/lib/active_record/postgres_enum/command_recorder.rb +++ b/lib/active_record/postgres_enum/command_recorder.rb @@ -3,7 +3,7 @@ module ActiveRecord module PostgresEnum module CommandRecorder - def create_enum(name, values) + def create_enum(name, values, _opts = nil) record(:create_enum, [name, values]) end diff --git a/spec/active_record/migrations_spec.rb b/spec/active_record/migrations_spec.rb index ac0de8b..4bde5e4 100644 --- a/spec/active_record/migrations_spec.rb +++ b/spec/active_record/migrations_spec.rb @@ -5,7 +5,7 @@ RSpec.describe ActiveRecord::PostgresEnum::CommandRecorder do let(:connection) { ActiveRecord::Base.connection } - it "reverts create_enum" do + it "reverts create_enum with no options" do migration = build_migration { create_enum :genre, %w[drama comedy] } migration.migrate(:up) @@ -17,6 +17,18 @@ expect(connection.enum_types[:genre]).to be_nil end + it "reverts create_enum with options" do + migration = build_migration { create_enum :genre, %w[drama comedy], force: true, if_not_exists: true } + + migration.migrate(:up) + + expect(connection.enum_types[:genre]).to eq %w[drama comedy] + + migration.migrate(:down) + + expect(connection.enum_types[:genre]).to be_nil + end + it "reverts rename_enum" do build_migration { create_enum :genre, %w[drama comedy] }.migrate(:up)