From 02380af75cef67e203b5bbea77fa30284e22bb4e Mon Sep 17 00:00:00 2001 From: Alan Guo Xiang Tan Date: Wed, 18 Sep 2024 10:20:24 +0800 Subject: [PATCH] PERF: Update migration to drop index concurrently. (#28955) This avoids locking the index's table --- db/migrate/20240912061806_drop_trgm_indexes_on_users.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/db/migrate/20240912061806_drop_trgm_indexes_on_users.rb b/db/migrate/20240912061806_drop_trgm_indexes_on_users.rb index f31b33a21f6..6d1a0f25216 100644 --- a/db/migrate/20240912061806_drop_trgm_indexes_on_users.rb +++ b/db/migrate/20240912061806_drop_trgm_indexes_on_users.rb @@ -1,9 +1,14 @@ # frozen_string_literal: true class DropTrgmIndexesOnUsers < ActiveRecord::Migration[7.1] + disable_ddl_transaction! + def up execute <<~SQL - DROP INDEX IF EXISTS index_users_on_username_lower_trgm; - DROP INDEX IF EXISTS index_users_on_name_trgm; + DROP INDEX CONCURRENTLY IF EXISTS index_users_on_username_lower_trgm; + SQL + + execute <<~SQL + DROP INDEX CONCURRENTLY IF EXISTS index_users_on_name_trgm; SQL end