Skip to content

A platform for community discussion. Free, open, simple.

DEV: Drop search index on non-pm posts.

Guo Xiang Tan87de8948c071
diff --git a/db/migrate/20200820232017_drop_idx_regular_post_search_data.rb b/db/migrate/20200820232017_drop_idx_regular_post_search_data.rb
new file mode 100644
index 00000000000..c61920c6a7c
--- /dev/null
+++ b/db/migrate/20200820232017_drop_idx_regular_post_search_data.rb
@@ -0,0 +1,11 @@
+class DropIdxRegularPostSearchData < ActiveRecord::Migration[6.0]
+ def up
+ execute <<~SQL
+ DROP INDEX CONCURRENTLY IF EXISTS idx_regular_post_search_data
+ SQL
+ end
+
+ def down
+ raise ActiveRecord::IrreversibleMigration
+ end
+end
diff --git a/db/post_migrate/20200818084329_update_private_message_on_post_search_data.rb b/db/post_migrate/20200818084329_update_private_message_on_post_search_data.rb
index 225a4a4cb1e..cab2c49ebf4 100644
--- a/db/post_migrate/20200818084329_update_private_message_on_post_search_data.rb
+++ b/db/post_migrate/20200818084329_update_private_message_on_post_search_data.rb
@@ -34,13 +34,6 @@ class UpdatePrivateMessageOnPostSearchData < ActiveRecord::Migration[6.0]
end
def up
-
- # must drop index cause we do not want an enormous amount of work done
- # as we are changing data
- execute <<~SQL
- DROP INDEX CONCURRENTLY IF EXISTS idx_regular_post_search_data
- SQL
-
# Delete post_search_data of orphaned posts
execute <<~SQL
DELETE FROM post_search_data
@@ -69,11 +62,6 @@ class UpdatePrivateMessageOnPostSearchData < ActiveRecord::Migration[6.0]
update_private_message_flag
change_column_null(:post_search_data, :private_message, false)
end
-
- execute <<~SQL
- CREATE INDEX CONCURRENTLY idx_regular_post_search_data
- ON post_search_data USING GIN(search_data) WHERE NOT private_message
- SQL
end
def down