Skip to content

Commit 2e63d11

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 b0efa6d commit 2e63d11

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
@@ -54,11 +54,7 @@ def create_table(table_name, **options)
5454
end
5555

5656
def add_index(table_name, column_name, **options)
57-
if options[:algorithm] == :default
58-
options.delete :algorithm
59-
else
60-
options[:algorithm] = :concurrently
61-
end
57+
options[:algorithm] = :concurrently unless options.key?(:algorithm)
6258

6359
Helpers::Logger.say_method_call(:add_index, table_name, column_name, **options)
6460
without_timeout { super(table_name, column_name, **options) }

0 commit comments

Comments
 (0)