A platform for community discussion. Free, open, simple.
DEV: Fix bigint notifications id migration to deal with public schema (#28538)
Alan Guo Xiang Tan6832c7b7e770
diff --git a/db/migrate/20240820123404_copy_notifications_id_indexes.rb b/db/migrate/20240820123404_copy_notifications_id_indexes.rbindex 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.rbindex 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 indexesresults =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"]