A platform for community discussion. Free, open, simple.
FIX: Add extra tag_id, topic_id index to topic_tags (#35565)
Martin Brennanc452e4275f0d
diff --git a/app/models/topic_tag.rb b/app/models/topic_tag.rbindex b2ed69791a2..86bf022c3d1 100644--- a/app/models/topic_tag.rb+++ b/app/models/topic_tag.rb@@ -52,12 +52,13 @@ end# Table name: topic_tags## id :integer not null, primary key-# topic_id :integer not null-# tag_id :integer not null# created_at :datetime not null# updated_at :datetime not null+# tag_id :integer not null+# topic_id :integer not null## Indexes#+# index_topic_tags_on_tag_id_and_topic_id (tag_id,topic_id) UNIQUE# index_topic_tags_on_topic_id_and_tag_id (topic_id,tag_id) UNIQUE#diff --git a/db/migrate/20251023042602_add_extra_index_topic_tags.rb b/db/migrate/20251023042602_add_extra_index_topic_tags.rbnew file mode 100644index 00000000000..7a3b07b770f--- /dev/null+++ b/db/migrate/20251023042602_add_extra_index_topic_tags.rb@@ -0,0 +1,9 @@+# frozen_string_literal: true+class AddExtraIndexTopicTags < ActiveRecord::Migration[8.0]+ disable_ddl_transaction!++ def change+ remove_index :topic_tags, %i[tag_id topic_id], if_exists: true+ add_index :topic_tags, %i[tag_id topic_id], unique: true, algorithm: :concurrently+ end+end