mirror of https://github.com/zulip/zulip.git
models: Add (realm, create_time) index for the Attachment table.
This commit is contained in:
parent
224ea3aaed
commit
4c4a443002
|
@ -0,0 +1,23 @@
|
|||
# Generated by Django 5.0.6 on 2024-05-08 01:16
|
||||
|
||||
from django.contrib.postgres.operations import AddIndexConcurrently
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
atomic = False
|
||||
|
||||
dependencies = [
|
||||
("zerver", "0519_archivetransaction_restored_timestamp"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
AddIndexConcurrently(
|
||||
model_name="attachment",
|
||||
index=models.Index(
|
||||
models.F("realm"),
|
||||
models.F("create_time"),
|
||||
name="zerver_attachment_realm_create_time",
|
||||
),
|
||||
),
|
||||
]
|
|
@ -713,6 +713,15 @@ class Attachment(AbstractAttachment):
|
|||
# because ScheduledMessage is not subject to archiving.
|
||||
scheduled_messages = models.ManyToManyField("zerver.ScheduledMessage")
|
||||
|
||||
class Meta:
|
||||
indexes = [
|
||||
models.Index(
|
||||
"realm",
|
||||
"create_time",
|
||||
name="zerver_attachment_realm_create_time",
|
||||
),
|
||||
]
|
||||
|
||||
def is_claimed(self) -> bool:
|
||||
return self.messages.exists() or self.scheduled_messages.exists()
|
||||
|
||||
|
|
Loading…
Reference in New Issue