about summary refs log tree commit diff
diff options
context:
space:
mode:
authorClaire <claire.github-309c@sitedethib.com>2022-04-07 20:17:49 +0200
committerGitHub <noreply@github.com>2022-04-07 20:17:49 +0200
commit5f0fc639dada7a58d2bb5524b4ec081ee6cc143f (patch)
tree267c3f7a4e2fc6ec61e10f3d6f5902bbf848d154
parent465ee7792ff48905088efdf3df6f718081b5e244 (diff)
Fix error re-running some migrations if they get interrupted at the wrong moment (#17989)
-rw-r--r--lib/mastodon/migration_helpers.rb3
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/mastodon/migration_helpers.rb b/lib/mastodon/migration_helpers.rb
index e920ff88f..beef83362 100644
--- a/lib/mastodon/migration_helpers.rb
+++ b/lib/mastodon/migration_helpers.rb
@@ -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