models: Convert deprecated index_together option to indexes.

index_together is slated for removal in Django 5.1:
https://docs.djangoproject.com/en/4.2/internals/deprecation/#deprecation-removed-in-5-1

We set the optional index names to match the previously generated
index names to avoid adding new migrations.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg
2023-06-11 12:22:36 -07:00
committed by Tim Abbott
parent c238327899
commit 7e707270f0
9 changed files with 117 additions and 44 deletions

View File

@@ -127,7 +127,12 @@ class Migration(migrations.Migration):
migrations.RenameModel(
old_name="UserPresence",
new_name="UserPresenceOld",
)
),
migrations.RenameIndex(
model_name="userpresenceold",
old_name="zerver_userpresence_realm_id_timestamp_25f410da_idx",
new_name="zerver_userpresenceold_realm_id_timestamp_52ef5fd3_idx",
),
],
),
migrations.CreateModel(
@@ -164,8 +169,19 @@ class Migration(migrations.Migration):
),
),
],
options={
"index_together": {("realm", "last_active_time"), ("realm", "last_connected_time")},
},
),
migrations.AddIndex(
model_name="userpresence",
index=models.Index(
fields=["realm", "last_active_time"],
name="zerver_userpresence_realm_id_last_active_time_1c5aa9a2_idx",
),
),
migrations.AddIndex(
model_name="userpresence",
index=models.Index(
fields=["realm", "last_connected_time"],
name="zerver_userpresence_realm_id_last_connected_time_98d2fc9f_idx",
),
),
]