diff --git a/lib/safe-pg-migrations/plugins/blocking_activity_logger.rb b/lib/safe-pg-migrations/plugins/blocking_activity_logger.rb index a887ecf..9f03665 100644 --- a/lib/safe-pg-migrations/plugins/blocking_activity_logger.rb +++ b/lib/safe-pg-migrations/plugins/blocking_activity_logger.rb @@ -11,6 +11,11 @@ module BlockingActivityLogger RETRIABLE_SCHEMA_STATEMENTS.each do |method| define_method method do |*args, **options, &block| + args, options = if args.last.is_a?(Hash) + [args[..-2], args.last] + else + [args, {}] + end log_context = lambda do break unless SafePgMigrations.config.sensitive_logger diff --git a/test/StatementInsurer/remove_column_test.rb b/test/StatementInsurer/remove_column_test.rb index 1c55abb..1cfd0e6 100644 --- a/test/StatementInsurer/remove_column_test.rb +++ b/test/StatementInsurer/remove_column_test.rb @@ -55,5 +55,20 @@ def change assert_equal ['ALTER TABLE "users" DROP COLUMN "name"'], calls[2] end + + def test_remove_column_with_default_arguments + @connection.create_table(:users) { |t| t.string :name } + + @migration = + Class.new(ActiveRecord::Migration::Current) do + def change + remove_column(:users, :name, :string, null: false, default: 'Benaaaa') + end + end.new + + calls = record_calls(@connection, :execute) { run_migration } + + assert_equal ['ALTER TABLE "users" DROP COLUMN "name"'], calls[2] + end end end