From 6832c7b7e7700f9a6993d9da0dafd8dcbf4665de Mon Sep 17 00:00:00 2001 From: Alan Guo Xiang Tan Date: Mon, 26 Aug 2024 10:25:13 +0800 Subject: [PATCH] DEV: Fix bigint notifications id migration to deal with public schema (#28538) Follow up to 799a45a291e9f2bd94278f565e58874458768079 --- db/migrate/20240820123404_copy_notifications_id_indexes.rb | 2 +- db/migrate/20240820123406_drop_old_notification_id_indexes.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/db/migrate/20240820123404_copy_notifications_id_indexes.rb b/db/migrate/20240820123404_copy_notifications_id_indexes.rb index ea79bb165c8..41a24c023ae 100644 --- a/db/migrate/20240820123404_copy_notifications_id_indexes.rb +++ b/db/migrate/20240820123404_copy_notifications_id_indexes.rb @@ -15,7 +15,7 @@ class CopyNotificationsIdIndexes < ActiveRecord::Migration[7.0] # Copy existing indexes and suffix them with `_bigint` results = execute( - "SELECT indexname, indexdef FROM pg_indexes WHERE tablename = 'notifications' AND indexdef SIMILAR TO '%\\mid\\M%'", + "SELECT indexname, indexdef FROM pg_indexes WHERE tablename = 'notifications' AND indexdef SIMILAR TO '%\\mid\\M%' AND schemaname = 'public'", ) results.each do |res| indexname, indexdef = res["indexname"], res["indexdef"] diff --git a/db/migrate/20240820123406_drop_old_notification_id_indexes.rb b/db/migrate/20240820123406_drop_old_notification_id_indexes.rb index eebad27b97e..554b19ff41b 100644 --- a/db/migrate/20240820123406_drop_old_notification_id_indexes.rb +++ b/db/migrate/20240820123406_drop_old_notification_id_indexes.rb @@ -17,7 +17,7 @@ class DropOldNotificationIdIndexes < ActiveRecord::Migration[7.0] # Remove `_bigint` suffix from indexes results = execute( - "SELECT indexname, indexdef FROM pg_indexes WHERE tablename = 'notifications' AND indexdef SIMILAR TO '%\\mid\\M%'", + "SELECT indexname, indexdef FROM pg_indexes WHERE tablename = 'notifications' AND indexdef SIMILAR TO '%\\mid\\M%' AND schemaname = 'public'", ) results.each do |res| indexname, indexdef = res["indexname"], res["indexdef"]