Skip to content

Commit

Permalink
Merge pull request #61 from BClark88/fix-error-on-rollback
Browse files Browse the repository at this point in the history
Fix error on rollback
  • Loading branch information
bibendi authored May 28, 2024
2 parents d2ab897 + 6f572cd commit 0810a4b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/active_record/postgres_enum/command_recorder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
14 changes: 13 additions & 1 deletion spec/active_record/migrations_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)

Expand Down

0 comments on commit 0810a4b

Please sign in to comment.