0
0
mirror of https://github.com/django/django.git synced 2024-11-25 07:59:34 +01:00

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

This should make it more straightforward to move forward when
deprecation ends.
This commit is contained in:
Mariusz Felisiak 2022-07-21 07:05:50 +02:00 committed by GitHub
parent 0e76abb8c4
commit f810325721
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 4 deletions

View File

@ -189,14 +189,14 @@ class MigrationAutodetector:
self.generate_renamed_indexes()
# Generate removal of foo together.
self.generate_removed_altered_unique_together()
self.generate_removed_altered_index_together()
self.generate_removed_altered_index_together() # RemovedInDjango51Warning.
# Generate field operations.
self.generate_removed_fields()
self.generate_added_fields()
self.generate_altered_fields()
self.generate_altered_order_with_respect_to()
self.generate_altered_unique_together()
self.generate_altered_index_together()
self.generate_altered_index_together() # RemovedInDjango51Warning.
self.generate_added_indexes()
self.generate_added_constraints()
self.generate_altered_db_table()
@ -616,6 +616,7 @@ class MigrationAutodetector:
indexes = model_state.options.pop("indexes")
constraints = model_state.options.pop("constraints")
unique_together = model_state.options.pop("unique_together", None)
# RemovedInDjango51Warning.
index_together = model_state.options.pop("index_together", None)
order_with_respect_to = model_state.options.pop(
"order_with_respect_to", None
@ -745,6 +746,7 @@ class MigrationAutodetector:
),
dependencies=related_dependencies,
)
# RemovedInDjango51Warning.
if index_together:
self.add_operation(
app_label,
@ -834,6 +836,7 @@ class MigrationAutodetector:
related_fields[field_name] = field
# Generate option removal first
unique_together = model_state.options.pop("unique_together", None)
# RemovedInDjango51Warning.
index_together = model_state.options.pop("index_together", None)
if unique_together:
self.add_operation(
@ -843,6 +846,7 @@ class MigrationAutodetector:
unique_together=None,
),
)
# RemovedInDjango51Warning.
if index_together:
self.add_operation(
app_label,
@ -1500,6 +1504,7 @@ class MigrationAutodetector:
def generate_removed_altered_unique_together(self):
self._generate_removed_altered_foo_together(operations.AlterUniqueTogether)
# RemovedInDjango51Warning.
def generate_removed_altered_index_together(self):
self._generate_removed_altered_foo_together(operations.AlterIndexTogether)
@ -1522,6 +1527,7 @@ class MigrationAutodetector:
def generate_altered_unique_together(self):
self._generate_altered_foo_together(operations.AlterUniqueTogether)
# RemovedInDjango51Warning.
def generate_altered_index_together(self):
self._generate_altered_foo_together(operations.AlterIndexTogether)

View File

@ -1841,6 +1841,7 @@ class Model(metaclass=ModelBase):
)
return errors
# RemovedInDjango51Warning.
@classmethod
def _check_index_together(cls):
"""Check the value of "index_together" option."""

View File

@ -42,6 +42,7 @@ DEFAULT_NAMES = (
"proxy",
"swappable",
"auto_created",
# Must be kept for backward compatibility with old migrations.
"index_together",
"apps",
"default_permissions",
@ -115,7 +116,7 @@ class Options:
self.indexes = []
self.constraints = []
self.unique_together = []
self.index_together = []
self.index_together = [] # RemovedInDjango51Warning.
self.select_on_save = False
self.default_permissions = ("add", "change", "delete", "view")
self.permissions = []

View File

@ -2491,7 +2491,6 @@ class OperationTests(OperationTestBase):
atomic=connection.features.supports_atomic_references_rename,
)
@ignore_warnings(category=RemovedInDjango51Warning)
def test_rename_field(self):
"""
Tests the RenameField operation.