DEV: Fix migration that adds index to incoming_emails topic_id (#26007)

Why this change?

Follow up to f880f1a42f. When adding an
index concurrently where the database transaction is disabled, we have
to ensure that we drop the index first if it exists because an invalid
index can be created if the migration has failed before.
This commit is contained in:
Alan Guo Xiang Tan 2024-03-04 16:52:20 +08:00 committed by GitHub
parent 955339668b
commit 7036a4295d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -2,7 +2,12 @@
class TopicIdOnIncomingEmailIndex < ActiveRecord::Migration[7.0]
disable_ddl_transaction!
def change
def up
remove_index :incoming_emails, :topic_id, if_exists: true
add_index :incoming_emails, :topic_id, algorithm: :concurrently
end
def down
raise ActiveRecord::IrreversibleMigration
end
end