Skip to content

Commit

Permalink
Improved code
Browse files Browse the repository at this point in the history
  • Loading branch information
ankane committed Nov 8, 2024
1 parent ba1ccdd commit 9c6ba16
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions lib/strong_migrations/checker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -247,11 +247,12 @@ def retry_lock_timeouts?(method)

# REINDEX INDEX CONCURRENTLY leaves a new invalid index if it fails, so use remove_index instead
def remove_invalid_index_if_needed(*args, **options)
if direction == :up && (index_name = invalid_index_name(*args, **options))
@migration.say("Attempting to remove invalid index")
# TODO pass index schema for extra safety?
@migration.remove_index(args[0], **{name: index_name}.merge(options.slice(:algorithm)))
end
index_name = invalid_index_name(*args, **options)
return if index_name.nil?

@migration.say("Attempting to remove invalid index")
# TODO pass index schema for extra safety?
@migration.remove_index(args[0], **{name: index_name}.merge(options.slice(:algorithm)))
end

def invalid_index_name(*args, **options)
Expand Down

0 comments on commit 9c6ba16

Please sign in to comment.