Make some of 4.7 migrations more resilient to being interrupted (#40264)

This commit is contained in:
Claire committed 2026-08-28 15:44:32 +02:00
1 parent f5becd6c39
commit 053c1774f8
2 files changed
+14 -2

No files matched your search

@@ -3,7 +3,13 @@
class AddIndexAccountIdLocalFragmentToKeypair < ActiveRecord::Migration[8.1]
disable_ddl_transaction!
def change
def up
add_index :keypairs, [:account_id, :local_fragment], unique: true, where: 'local_fragment IS NOT NULL', algorithm: :concurrently
rescue ActiveRecord::StatementInvalid
safety_assured { execute 'REINDEX INDEX CONCURRENTLY index_keypairs_on_account_id_and_local_fragment' }
end
def down
remove_index :keypairs, name: :index_keypairs_on_account_id_and_local_fragment
end
end
@@ -3,7 +3,13 @@
class AddNewIndexAccountIdLocalFragmentToKeypair < ActiveRecord::Migration[8.1]
disable_ddl_transaction!
def change
def up
add_index :keypairs, [:account_id, :local_fragment], unique: true, name: :index_keypairs_on_account_id_and_local_fragment, algorithm: :concurrently
rescue ActiveRecord::StatementInvalid
safety_assured { execute 'REINDEX INDEX CONCURRENTLY index_keypairs_on_account_id_and_local_fragment' }
end
def down
remove_index :keypairs, name: :index_keypairs_on_account_id_and_local_fragment
end
end