migrations: Remove indexes on Message without realm_id.

These indexes should no longer be necessary after the changes in the
previous commit.
This commit is contained in:
Alex Vandiver 2023-09-01 00:45:39 +00:00 committed by Tim Abbott
parent b94402152d
commit 5874c6542f
2 changed files with 29 additions and 21 deletions

View File

@ -0,0 +1,29 @@
from django.contrib.postgres.operations import RemoveIndexConcurrently
from django.db import migrations
class Migration(migrations.Migration):
atomic = False
dependencies = [
("zerver", "0472_add_message_realm_id_indexes"),
]
operations = [
RemoveIndexConcurrently(
model_name="message",
name="upper_subject_idx",
),
RemoveIndexConcurrently(
model_name="message",
name="zerver_message_recipient_upper_subject",
),
RemoveIndexConcurrently(
model_name="message",
name="zerver_message_recipient_subject",
),
RemoveIndexConcurrently(
model_name="scheduledmessage",
name="zerver_unsent_scheduled_messages_by_user",
),
]

View File

@ -3103,20 +3103,6 @@ class Message(AbstractMessage):
class Meta: class Meta:
indexes = [ indexes = [
GinIndex("search_tsvector", fastupdate=False, name="zerver_message_search_tsvector"), GinIndex("search_tsvector", fastupdate=False, name="zerver_message_search_tsvector"),
models.Index(Upper("subject"), name="upper_subject_idx"),
models.Index(
"recipient",
Upper("subject"),
F("id").desc(nulls_last=True),
name="zerver_message_recipient_upper_subject",
),
models.Index(
"recipient",
"subject",
F("id").desc(nulls_last=True),
name="zerver_message_recipient_subject",
),
# Indexes prefixed with realm_id
models.Index( models.Index(
# For moving messages between streams or marking # For moving messages between streams or marking
# streams as read. The "id" at the end makes it easy # streams as read. The "id" at the end makes it easy
@ -4475,13 +4461,6 @@ class ScheduledMessage(models.Model):
# user themself via the API; we don't filter failed # user themself via the API; we don't filter failed
# messages since we will want to display those so that # messages since we will want to display those so that
# failures don't just disappear into a black hole. # failures don't just disappear into a black hole.
models.Index(
name="zerver_unsent_scheduled_messages_by_user",
fields=["sender", "delivery_type", "scheduled_timestamp"],
condition=Q(
delivered=False,
),
),
models.Index( models.Index(
name="zerver_realm_unsent_scheduled_messages_by_user", name="zerver_realm_unsent_scheduled_messages_by_user",
fields=["realm_id", "sender", "delivery_type", "scheduled_timestamp"], fields=["realm_id", "sender", "delivery_type", "scheduled_timestamp"],