]> cat aescling's git repositories - mastodon.git/commitdiff
Fix error re-running some migrations if they get interrupted at the wrong moment...
authorClaire <claire.github-309c@sitedethib.com>
Thu, 7 Apr 2022 18:17:49 +0000 (20:17 +0200)
committerGitHub <noreply@github.com>
Thu, 7 Apr 2022 18:17:49 +0000 (20:17 +0200)
lib/mastodon/migration_helpers.rb

index e920ff88fd7f86f9aa6e60c7ce763acbf8d3c9bd..beef833621c1fc4556b7c092a7714515a0972fe8 100644 (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