diff options
author | David Wobrock <david.wobrock@gmail.com> | 2022-05-17 16:13:35 +0200 |
---|---|---|
committer | David Wobrock <david.wobrock@gmail.com> | 2022-07-12 09:04:31 +0200 |
commit | a6385b382e05a614a99e5a5913d8e631823159a2 (patch) | |
tree | 63e10468533956576c76593b7dba26a03c0058da /tests/check_framework | |
parent | 4f284115a9181990f713d5167b25628fa171a5e4 (diff) | |
download | django-a6385b382e05a614a99e5a5913d8e631823159a2.tar.gz |
Fixed #27236 -- Deprecated Meta.index_together in favor of Meta.indexes.
This also deprecates AlterIndexTogether migration operation.
Diffstat (limited to 'tests/check_framework')
6 files changed, 42 insertions, 0 deletions
diff --git a/tests/check_framework/migrations_test_apps/__init__.py b/tests/check_framework/migrations_test_apps/__init__.py new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/tests/check_framework/migrations_test_apps/__init__.py diff --git a/tests/check_framework/migrations_test_apps/index_together_app/__init__.py b/tests/check_framework/migrations_test_apps/index_together_app/__init__.py new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/tests/check_framework/migrations_test_apps/index_together_app/__init__.py diff --git a/tests/check_framework/migrations_test_apps/index_together_app/apps.py b/tests/check_framework/migrations_test_apps/index_together_app/apps.py new file mode 100644 index 0000000000..3bb7170897 --- /dev/null +++ b/tests/check_framework/migrations_test_apps/index_together_app/apps.py @@ -0,0 +1,5 @@ +from django.apps import AppConfig + + +class IndexTogetherAppConfig(AppConfig): + name = "check_framework.migrations_test_apps.index_together_app" diff --git a/tests/check_framework/migrations_test_apps/index_together_app/migrations/0001_initial.py b/tests/check_framework/migrations_test_apps/index_together_app/migrations/0001_initial.py new file mode 100644 index 0000000000..c642ee6c57 --- /dev/null +++ b/tests/check_framework/migrations_test_apps/index_together_app/migrations/0001_initial.py @@ -0,0 +1,16 @@ +from django.db import migrations, models + + +class Migration(migrations.Migration): + + initial = True + + operations = [ + migrations.CreateModel( + "SimpleModel", + [ + ("field", models.IntegerField()), + ], + ), + migrations.AlterIndexTogether("SimpleModel", index_together=(("id", "field"),)), + ] diff --git a/tests/check_framework/migrations_test_apps/index_together_app/migrations/__init__.py b/tests/check_framework/migrations_test_apps/index_together_app/migrations/__init__.py new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/tests/check_framework/migrations_test_apps/index_together_app/migrations/__init__.py diff --git a/tests/check_framework/test_migrations.py b/tests/check_framework/test_migrations.py index 0b00690e77..e41a68fa54 100644 --- a/tests/check_framework/test_migrations.py +++ b/tests/check_framework/test_migrations.py @@ -1,7 +1,11 @@ +from unittest.mock import ANY + from django.core import checks +from django.core.checks.migrations import check_migration_operations from django.db import migrations from django.db.migrations.operations.base import Operation from django.test import TestCase +from django.test.utils import override_settings class DeprecatedMigrationOperationTests(TestCase): @@ -50,6 +54,23 @@ class DeprecatedMigrationOperationTests(TestCase): ], ) + @override_settings( + INSTALLED_APPS=["check_framework.migrations_test_apps.index_together_app"] + ) + def tests_check_alter_index_together(self): + errors = check_migration_operations() + self.assertEqual( + errors, + [ + checks.Warning( + "AlterIndexTogether is deprecated. Support for it (except in " + "historical migrations) will be removed in Django 5.1.", + obj=ANY, + id="migrations.W001", + ) + ], + ) + class RemovedMigrationOperationTests(TestCase): def test_default_operation(self): |