mirror of
https://github.com/zulip/zulip.git
synced 2025-11-07 07:23:22 +00:00
models: Manage index from migration 0244 with Django.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
committed by
Tim Abbott
parent
0799acf3b6
commit
cf0eb46afc
@@ -1,6 +1,7 @@
|
|||||||
import time
|
import time
|
||||||
|
|
||||||
from django.db import connection, migrations
|
from django.contrib.postgres.operations import AddIndexConcurrently
|
||||||
|
from django.db import connection, migrations, models
|
||||||
from django.db.backends.postgresql.schema import DatabaseSchemaEditor
|
from django.db.backends.postgresql.schema import DatabaseSchemaEditor
|
||||||
from django.db.migrations.state import StateApps
|
from django.db.migrations.state import StateApps
|
||||||
from django.db.models import Min
|
from django.db.models import Min
|
||||||
@@ -78,11 +79,8 @@ class Migration(migrations.Migration):
|
|||||||
"""
|
"""
|
||||||
),
|
),
|
||||||
migrations.RunPython(copy_pub_date_to_date_sent, elidable=True),
|
migrations.RunPython(copy_pub_date_to_date_sent, elidable=True),
|
||||||
# The name for the index was chosen to match the name of the index Django would create
|
AddIndexConcurrently(
|
||||||
# in a normal migration with AlterField of date_sent to have db_index=True:
|
model_name="message",
|
||||||
migrations.RunSQL(
|
index=models.Index("date_sent", name="zerver_message_date_sent_3b5b05d8"),
|
||||||
"""
|
|
||||||
CREATE INDEX CONCURRENTLY zerver_message_date_sent_3b5b05d8 ON zerver_message (date_sent);
|
|
||||||
"""
|
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -2801,6 +2801,7 @@ class Message(AbstractMessage):
|
|||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
indexes = [
|
indexes = [
|
||||||
|
models.Index("date_sent", name="zerver_message_date_sent_3b5b05d8"),
|
||||||
models.Index(
|
models.Index(
|
||||||
"recipient",
|
"recipient",
|
||||||
Upper("subject"),
|
Upper("subject"),
|
||||||
|
|||||||
Reference in New Issue
Block a user