Skip to content

Commit e43f478

Browse files
committed
Update logic for overriding :algorithm in add_index
Rails (at least version 7.1) raises an error if the `:algorithm` option is set to :default, before this code gets invoked. Instead of allowing a custom `:default` option, we can instead just check whether the options[:algorithm] key is present. This is what the `remove_index` method below does, and allows us to use `algorithm: nil` to disable the `:concurrently` option.
1 parent 55a4670 commit e43f478

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

lib/safe-pg-migrations/plugins/statement_insurer.rb

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,7 @@ module StatementInsurer # rubocop:disable Metrics/ModuleLength
6565
end
6666

6767
def add_index(table_name, column_name, **options)
68-
if options[:algorithm] == :default
69-
options.delete :algorithm
70-
else
71-
options[:algorithm] = :concurrently
72-
end
68+
options[:algorithm] = :concurrently unless options.key?(:algorithm)
7369

7470
SafePgMigrations.say_method_call(:add_index, table_name, column_name, **options)
7571

0 commit comments

Comments
 (0)