PERF: Update migration to drop index concurrently. (#28955)

This avoids locking the index's table
This commit is contained in:
Alan Guo Xiang Tan 2024-09-18 10:20:24 +08:00 committed by GitHub
parent 9a2e6fc890
commit 02380af75c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 7 additions and 2 deletions

View File

@ -1,9 +1,14 @@
# frozen_string_literal: true # frozen_string_literal: true
class DropTrgmIndexesOnUsers < ActiveRecord::Migration[7.1] class DropTrgmIndexesOnUsers < ActiveRecord::Migration[7.1]
disable_ddl_transaction!
def up def up
execute <<~SQL execute <<~SQL
DROP INDEX IF EXISTS index_users_on_username_lower_trgm; DROP INDEX CONCURRENTLY IF EXISTS index_users_on_username_lower_trgm;
DROP INDEX IF EXISTS index_users_on_name_trgm; SQL
execute <<~SQL
DROP INDEX CONCURRENTLY IF EXISTS index_users_on_name_trgm;
SQL SQL
end end