1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

Fixed #27236 -- Deprecated Meta.index_together in favor of Meta.indexes.

This also deprecates AlterIndexTogether migration operation.
This commit is contained in:
David Wobrock
2022-05-17 16:13:35 +02:00
parent 4f284115a9
commit a6385b382e
22 changed files with 178 additions and 14 deletions

View File

@@ -13,8 +13,9 @@ from django.db.migrations.state import (
ProjectState,
get_related_models_recursive,
)
from django.test import SimpleTestCase, override_settings
from django.test import SimpleTestCase, ignore_warnings, override_settings
from django.test.utils import isolate_apps
from django.utils.deprecation import RemovedInDjango51Warning
from .models import (
FoodManager,
@@ -30,6 +31,9 @@ class StateTests(SimpleTestCase):
Tests state construction, rendering and modification by operations.
"""
# RemovedInDjango51Warning, when deprecation ends, only remove
# Meta.index_together from inline models.
@ignore_warnings(category=RemovedInDjango51Warning)
def test_create(self):
"""
Tests making a ProjectState from an Apps
@@ -46,7 +50,7 @@ class StateTests(SimpleTestCase):
app_label = "migrations"
apps = new_apps
unique_together = ["name", "bio"]
index_together = ["bio", "age"]
index_together = ["bio", "age"] # RemovedInDjango51Warning.
class AuthorProxy(Author):
class Meta:
@@ -140,7 +144,7 @@ class StateTests(SimpleTestCase):
author_state.options,
{
"unique_together": {("name", "bio")},
"index_together": {("bio", "age")},
"index_together": {("bio", "age")}, # RemovedInDjango51Warning.
"indexes": [],
"constraints": [],
},