Refs #27236 -- Made more cosmetic edits to Meta.index_together deprecation.

This commit is contained in:
Mariusz Felisiak 2023-05-05 09:26:51 +02:00 committed by GitHub
parent 024954aad4
commit ca5d3c99ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 4 deletions

View File

@ -1496,6 +1496,7 @@ class BaseDatabaseSchemaEditor:
for field in model._meta.local_fields:
output.extend(self._field_indexes_sql(model, field))
# RemovedInDjango51Warning.
for field_names in model._meta.index_together:
fields = [model._meta.get_field(field) for field in field_names]
output.append(self._create_index_sql(model, fields=fields, suffix="_idx"))

View File

@ -272,6 +272,7 @@ class DatabaseSchemaEditor(BaseDatabaseSchemaEditor):
for unique in model._meta.unique_together
]
# RemovedInDjango51Warning.
# Work out the new value for index_together, taking renames into
# account
index_together = [
@ -301,7 +302,7 @@ class DatabaseSchemaEditor(BaseDatabaseSchemaEditor):
"app_label": model._meta.app_label,
"db_table": model._meta.db_table,
"unique_together": unique_together,
"index_together": index_together,
"index_together": index_together, # RemovedInDjango51Warning.
"indexes": indexes,
"constraints": constraints,
"apps": apps,
@ -317,7 +318,7 @@ class DatabaseSchemaEditor(BaseDatabaseSchemaEditor):
"app_label": model._meta.app_label,
"db_table": "new__%s" % strip_quotes(model._meta.db_table),
"unique_together": unique_together,
"index_together": index_together,
"index_together": index_together, # RemovedInDjango51Warning.
"indexes": indexes,
"constraints": constraints,
"apps": apps,

View File

@ -43,8 +43,7 @@ DEFAULT_NAMES = (
"proxy",
"swappable",
"auto_created",
# Must be kept for backward compatibility with old migrations.
"index_together",
"index_together", # RemovedInDjango51Warning.
"apps",
"default_permissions",
"select_on_save",