Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

models: Manage index from migration 0112 with Django.

Anders Kaseorg903e2196545e
diff --git a/zerver/migrations/0112_index_muted_topics.py b/zerver/migrations/0112_index_muted_topics.py
index 5e6e7731376..f79d104dcd6 100644
--- a/zerver/migrations/0112_index_muted_topics.py
+++ b/zerver/migrations/0112_index_muted_topics.py
@@ -1,4 +1,5 @@
-from django.db import migrations
+from django.db import migrations, models
+from django.db.models.functions import Upper
class Migration(migrations.Migration):
@@ -8,12 +9,10 @@ class Migration(migrations.Migration):
]
operations = [
- migrations.RunSQL(
- """
- CREATE INDEX zerver_mutedtopic_stream_topic
- ON zerver_mutedtopic
- (stream_id, upper(topic_name))
- """,
- reverse_sql="DROP INDEX zerver_mutedtopic_stream_topic;",
+ migrations.AddIndex(
+ model_name="mutedtopic",
+ index=models.Index(
+ "stream", Upper("topic_name"), name="zerver_mutedtopic_stream_topic"
+ ),
),
]
diff --git a/zerver/models.py b/zerver/models.py
index a7246908252..46242011328 100644
--- a/zerver/models.py
+++ b/zerver/models.py
@@ -2460,6 +2460,7 @@ class UserTopic(models.Model):
unique_together = ("user_profile", "stream", "topic_name")
indexes = [
+ models.Index("stream", Upper("topic_name"), name="zerver_mutedtopic_stream_topic"),
# This index is designed to optimize queries fetching the
# set of users who have special policy for a stream,
# e.g. for the send-message code paths.