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

This commit is contained in:
Claire
2026-08-27 08:07:02 +00:00
committed by GitHub
parent 47ac677a9b
commit dc317afb11
2 changed files with 14 additions and 2 deletions

View File

@@ -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

View File

@@ -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