Fix error re-running some migrations if they get interrupted at the wrong moment (#17989)

lolsob-rspec
Claire 2022-04-07 20:17:49 +02:00 committed by GitHub
parent aa6bc541d3
commit 2b7d558807
1 changed files with 3 additions and 0 deletions

View File

@ -813,6 +813,9 @@ module Mastodon
def update_index(table_name, index_name, columns, **index_options)
if index_name_exists?(table_name, "#{index_name}_new") && index_name_exists?(table_name, index_name)
remove_index table_name, "#{index_name}_new"
elsif index_name_exists?(table_name, "#{index_name}_new")
# Very unlikely case where the script has been interrupted during/after removal but before renaming
rename_index table_name, "#{index_name}_new", index_name
end
begin