Skip to content

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

DEV: Add index for livestream_topic_chat_channels on chat_channel_id (#43873)

Martin Brennan55e281f84ab4
diff --git a/db/structure.sql b/db/structure.sql
index 8167387f770..4d401995cfe 100644
--- a/db/structure.sql
+++ b/db/structure.sql
@@ -22181,6 +22181,13 @@ CREATE UNIQUE INDEX index_linked_topics_on_topic_id_and_original_topic_id ON pub
CREATE UNIQUE INDEX index_linked_topics_on_topic_id_and_sequence ON public.linked_topics USING btree (topic_id, sequence);
+--
+-- Name: index_livestream_topic_chat_channels_on_chat_channel_id; Type: INDEX; Schema: public; Owner: -
+--
+
+CREATE INDEX index_livestream_topic_chat_channels_on_chat_channel_id ON public.livestream_topic_chat_channels USING btree (chat_channel_id);
+
+
--
-- Name: index_llm_credit_allocations_on_llm_model_id; Type: INDEX; Schema: public; Owner: -
--
@@ -25383,6 +25390,7 @@ ALTER TABLE ONLY public.ad_plugin_house_ads_groups
SET search_path TO "$user", public;
INSERT INTO "schema_migrations" (version) VALUES
+('20260921015711'),
('20260915204557'),
('20260915191328'),
('20260914213908'),
diff --git a/plugins/discourse-events/app/models/discourse_events/livestream/topic_chat_channel.rb b/plugins/discourse-events/app/models/discourse_events/livestream/topic_chat_channel.rb
index c0e1dd6ff7f..8935b8a8274 100644
--- a/plugins/discourse-events/app/models/discourse_events/livestream/topic_chat_channel.rb
+++ b/plugins/discourse-events/app/models/discourse_events/livestream/topic_chat_channel.rb
@@ -23,5 +23,6 @@ end
#
# Indexes
#
-# unique_livestream_topic_chat_channels (topic_id,chat_channel_id) UNIQUE
+# index_livestream_topic_chat_channels_on_chat_channel_id (chat_channel_id)
+# unique_livestream_topic_chat_channels (topic_id,chat_channel_id) UNIQUE
#
diff --git a/plugins/discourse-events/db/migrate/20260921015711_add_index_to_livestream_topic_chat_channels_on_chat_channel_id.rb b/plugins/discourse-events/db/migrate/20260921015711_add_index_to_livestream_topic_chat_channels_on_chat_channel_id.rb
new file mode 100644
index 00000000000..a362502f6b6
--- /dev/null
+++ b/plugins/discourse-events/db/migrate/20260921015711_add_index_to_livestream_topic_chat_channels_on_chat_channel_id.rb
@@ -0,0 +1,7 @@
+# frozen_string_literal: true
+
+class AddIndexToLivestreamTopicChatChannelsOnChatChannelId < ActiveRecord::Migration[8.0]
+ def change
+ add_index :livestream_topic_chat_channels, :chat_channel_id
+ end
+end