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:
parent
0e76abb8c4
commit
f810325721
@ -189,14 +189,14 @@ class MigrationAutodetector:
|
|||||||
self.generate_renamed_indexes()
|
self.generate_renamed_indexes()
|
||||||
# Generate removal of foo together.
|
# Generate removal of foo together.
|
||||||
self.generate_removed_altered_unique_together()
|
self.generate_removed_altered_unique_together()
|
||||||
self.generate_removed_altered_index_together()
|
self.generate_removed_altered_index_together() # RemovedInDjango51Warning.
|
||||||
# Generate field operations.
|
# Generate field operations.
|
||||||
self.generate_removed_fields()
|
self.generate_removed_fields()
|
||||||
self.generate_added_fields()
|
self.generate_added_fields()
|
||||||
self.generate_altered_fields()
|
self.generate_altered_fields()
|
||||||
self.generate_altered_order_with_respect_to()
|
self.generate_altered_order_with_respect_to()
|
||||||
self.generate_altered_unique_together()
|
self.generate_altered_unique_together()
|
||||||
self.generate_altered_index_together()
|
self.generate_altered_index_together() # RemovedInDjango51Warning.
|
||||||
self.generate_added_indexes()
|
self.generate_added_indexes()
|
||||||
self.generate_added_constraints()
|
self.generate_added_constraints()
|
||||||
self.generate_altered_db_table()
|
self.generate_altered_db_table()
|
||||||
@ -616,6 +616,7 @@ class MigrationAutodetector:
|
|||||||
indexes = model_state.options.pop("indexes")
|
indexes = model_state.options.pop("indexes")
|
||||||
constraints = model_state.options.pop("constraints")
|
constraints = model_state.options.pop("constraints")
|
||||||
unique_together = model_state.options.pop("unique_together", None)
|
unique_together = model_state.options.pop("unique_together", None)
|
||||||
|
# RemovedInDjango51Warning.
|
||||||
index_together = model_state.options.pop("index_together", None)
|
index_together = model_state.options.pop("index_together", None)
|
||||||
order_with_respect_to = model_state.options.pop(
|
order_with_respect_to = model_state.options.pop(
|
||||||
"order_with_respect_to", None
|
"order_with_respect_to", None
|
||||||
@ -745,6 +746,7 @@ class MigrationAutodetector:
|
|||||||
),
|
),
|
||||||
dependencies=related_dependencies,
|
dependencies=related_dependencies,
|
||||||
)
|
)
|
||||||
|
# RemovedInDjango51Warning.
|
||||||
if index_together:
|
if index_together:
|
||||||
self.add_operation(
|
self.add_operation(
|
||||||
app_label,
|
app_label,
|
||||||
@ -834,6 +836,7 @@ class MigrationAutodetector:
|
|||||||
related_fields[field_name] = field
|
related_fields[field_name] = field
|
||||||
# Generate option removal first
|
# Generate option removal first
|
||||||
unique_together = model_state.options.pop("unique_together", None)
|
unique_together = model_state.options.pop("unique_together", None)
|
||||||
|
# RemovedInDjango51Warning.
|
||||||
index_together = model_state.options.pop("index_together", None)
|
index_together = model_state.options.pop("index_together", None)
|
||||||
if unique_together:
|
if unique_together:
|
||||||
self.add_operation(
|
self.add_operation(
|
||||||
@ -843,6 +846,7 @@ class MigrationAutodetector:
|
|||||||
unique_together=None,
|
unique_together=None,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
# RemovedInDjango51Warning.
|
||||||
if index_together:
|
if index_together:
|
||||||
self.add_operation(
|
self.add_operation(
|
||||||
app_label,
|
app_label,
|
||||||
@ -1500,6 +1504,7 @@ class MigrationAutodetector:
|
|||||||
def generate_removed_altered_unique_together(self):
|
def generate_removed_altered_unique_together(self):
|
||||||
self._generate_removed_altered_foo_together(operations.AlterUniqueTogether)
|
self._generate_removed_altered_foo_together(operations.AlterUniqueTogether)
|
||||||
|
|
||||||
|
# RemovedInDjango51Warning.
|
||||||
def generate_removed_altered_index_together(self):
|
def generate_removed_altered_index_together(self):
|
||||||
self._generate_removed_altered_foo_together(operations.AlterIndexTogether)
|
self._generate_removed_altered_foo_together(operations.AlterIndexTogether)
|
||||||
|
|
||||||
@ -1522,6 +1527,7 @@ class MigrationAutodetector:
|
|||||||
def generate_altered_unique_together(self):
|
def generate_altered_unique_together(self):
|
||||||
self._generate_altered_foo_together(operations.AlterUniqueTogether)
|
self._generate_altered_foo_together(operations.AlterUniqueTogether)
|
||||||
|
|
||||||
|
# RemovedInDjango51Warning.
|
||||||
def generate_altered_index_together(self):
|
def generate_altered_index_together(self):
|
||||||
self._generate_altered_foo_together(operations.AlterIndexTogether)
|
self._generate_altered_foo_together(operations.AlterIndexTogether)
|
||||||
|
|
||||||
|
@ -1841,6 +1841,7 @@ class Model(metaclass=ModelBase):
|
|||||||
)
|
)
|
||||||
return errors
|
return errors
|
||||||
|
|
||||||
|
# RemovedInDjango51Warning.
|
||||||
@classmethod
|
@classmethod
|
||||||
def _check_index_together(cls):
|
def _check_index_together(cls):
|
||||||
"""Check the value of "index_together" option."""
|
"""Check the value of "index_together" option."""
|
||||||
|
@ -42,6 +42,7 @@ DEFAULT_NAMES = (
|
|||||||
"proxy",
|
"proxy",
|
||||||
"swappable",
|
"swappable",
|
||||||
"auto_created",
|
"auto_created",
|
||||||
|
# Must be kept for backward compatibility with old migrations.
|
||||||
"index_together",
|
"index_together",
|
||||||
"apps",
|
"apps",
|
||||||
"default_permissions",
|
"default_permissions",
|
||||||
@ -115,7 +116,7 @@ class Options:
|
|||||||
self.indexes = []
|
self.indexes = []
|
||||||
self.constraints = []
|
self.constraints = []
|
||||||
self.unique_together = []
|
self.unique_together = []
|
||||||
self.index_together = []
|
self.index_together = [] # RemovedInDjango51Warning.
|
||||||
self.select_on_save = False
|
self.select_on_save = False
|
||||||
self.default_permissions = ("add", "change", "delete", "view")
|
self.default_permissions = ("add", "change", "delete", "view")
|
||||||
self.permissions = []
|
self.permissions = []
|
||||||
|
@ -2491,7 +2491,6 @@ class OperationTests(OperationTestBase):
|
|||||||
atomic=connection.features.supports_atomic_references_rename,
|
atomic=connection.features.supports_atomic_references_rename,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ignore_warnings(category=RemovedInDjango51Warning)
|
|
||||||
def test_rename_field(self):
|
def test_rename_field(self):
|
||||||
"""
|
"""
|
||||||
Tests the RenameField operation.
|
Tests the RenameField operation.
|
||||||
|
Loading…
Reference in New Issue
Block a user