mirror of https://github.com/zulip/zulip.git
models: Remove duplicate index definition for date_sent.
Commit cf0eb46afc
added this to let
Django understand the CREATE INDEX CONCURRENTLY statement that had
been hidden in a RunSQL query in migration 0244. However, migration
0245 explained that same index to Django in a different way by setting
db_index=True. Move that to 0244 where the index is actually created,
using SeparateDatabaseAndState.
Also remove the part of the SQL in 0245 that was mirrored by dummy
state_operations, and replace it with real operations.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
parent
0a424f0c5e
commit
2cd018ce57
|
@ -79,8 +79,19 @@ class Migration(migrations.Migration):
|
||||||
"""
|
"""
|
||||||
),
|
),
|
||||||
migrations.RunPython(copy_pub_date_to_date_sent, elidable=True),
|
migrations.RunPython(copy_pub_date_to_date_sent, elidable=True),
|
||||||
AddIndexConcurrently(
|
migrations.SeparateDatabaseAndState(
|
||||||
model_name="message",
|
database_operations=[
|
||||||
index=models.Index("date_sent", name="zerver_message_date_sent_3b5b05d8"),
|
AddIndexConcurrently(
|
||||||
|
model_name="message",
|
||||||
|
index=models.Index("date_sent", name="zerver_message_date_sent_3b5b05d8"),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
state_operations=[
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name="message",
|
||||||
|
name="date_sent",
|
||||||
|
field=models.DateTimeField(db_index=True, null=True, verbose_name="date sent"),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|
|
@ -13,19 +13,16 @@ class Migration(migrations.Migration):
|
||||||
"""
|
"""
|
||||||
DROP TRIGGER zerver_message_date_sent_to_pub_date_trigger ON zerver_message;
|
DROP TRIGGER zerver_message_date_sent_to_pub_date_trigger ON zerver_message;
|
||||||
DROP FUNCTION zerver_message_date_sent_to_pub_date_trigger_function();
|
DROP FUNCTION zerver_message_date_sent_to_pub_date_trigger_function();
|
||||||
|
"""
|
||||||
ALTER TABLE zerver_message ALTER COLUMN date_sent SET NOT NULL;
|
),
|
||||||
ALTER TABLE zerver_message ALTER COLUMN pub_date DROP NOT NULL;
|
migrations.AlterField(
|
||||||
""",
|
model_name="message",
|
||||||
state_operations=[
|
name="date_sent",
|
||||||
# This just tells Django to, after running the above SQL, consider the AlterField below
|
field=models.DateTimeField(db_index=True, verbose_name="date sent"),
|
||||||
# as done. The building of the index actually happened in the previous migration, not here,
|
),
|
||||||
# but nevertheless this seems like the correct place to put this fake AlterField.
|
migrations.AlterField(
|
||||||
migrations.AlterField(
|
model_name="message",
|
||||||
model_name="message",
|
name="pub_date",
|
||||||
name="date_sent",
|
field=models.DateTimeField(db_index=True, null=True, verbose_name="date published"),
|
||||||
field=models.DateTimeField(db_index=True, verbose_name="date sent"),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|
|
@ -3104,7 +3104,6 @@ class Message(AbstractMessage):
|
||||||
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(Upper("subject"), name="upper_subject_idx"),
|
||||||
models.Index("date_sent", name="zerver_message_date_sent_3b5b05d8"),
|
|
||||||
models.Index(
|
models.Index(
|
||||||
"recipient",
|
"recipient",
|
||||||
Upper("subject"),
|
Upper("subject"),
|
||||||
|
|
Loading…
Reference in New Issue