Skip to content

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

DEV: Drop plugin related index from core (#20930)

Alan Guo Xiang Tane54359c135b6
diff --git a/app/models/post_custom_field.rb b/app/models/post_custom_field.rb
index 58c8705fd5a..56cf46a90b6 100644
--- a/app/models/post_custom_field.rb
+++ b/app/models/post_custom_field.rb
@@ -17,7 +17,6 @@ end
#
# Indexes
#
-# idx_post_custom_fields_akismet (post_id) WHERE (((name)::text = 'AKISMET_STATE'::text) AND (value = 'needs_review'::text))
# index_post_custom_fields_on_name_and_value (name, "left"(value, 200))
# index_post_custom_fields_on_notice (post_id) UNIQUE WHERE ((name)::text = 'notice'::text)
# index_post_custom_fields_on_post_id (post_id) UNIQUE WHERE ((name)::text = 'missing uploads'::text)
diff --git a/db/migrate/20180327062911_add_post_custom_fields_akismet_index.rb b/db/migrate/20180327062911_add_post_custom_fields_akismet_index.rb
deleted file mode 100644
index 68b1483bcef..00000000000
--- a/db/migrate/20180327062911_add_post_custom_fields_akismet_index.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-# frozen_string_literal: true
-
-# This is our current pattern for data migrations needed by plugins, we prefer to keep them in core
-# so schema is tightly controlled, especially if we are amending tables owned by core
-#
-# this index makes looking up posts requiring review much faster (20ms on meta)
-
-class AddPostCustomFieldsAkismetIndex < ActiveRecord::Migration[5.1]
- def change
- add_index :post_custom_fields,
- [:post_id],
- name: "idx_post_custom_fields_akismet",
- where: "name = 'AKISMET_STATE' AND value = 'needs_review'"
- end
-end
diff --git a/db/migrate/20230403063113_drop_idx_post_custom_fields_akismet.rb b/db/migrate/20230403063113_drop_idx_post_custom_fields_akismet.rb
new file mode 100644
index 00000000000..8d9de3a5355
--- /dev/null
+++ b/db/migrate/20230403063113_drop_idx_post_custom_fields_akismet.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+# This plugin related index was added to core way back in 2018 but it should not have been added to core in the first place.
+# The index has since been moved into the plugin itself.
+class DropIdxPostCustomFieldsAkismet < ActiveRecord::Migration[7.0]
+ def up
+ execute "DROP INDEX IF EXISTS idx_post_custom_fields_akismet"
+ end
+
+ def down
+ raise ActiveRecord::IrreversibleMigration
+ end
+end