From c773d5794eb425c4836c726bdf6e1e742c94e9c0 Mon Sep 17 00:00:00 2001 From: Mariusz Felisiak Date: Wed, 20 Jul 2022 07:33:03 +0200 Subject: [PATCH] Refs #27236 -- Reverted AlterIndexTogether deprecation. This partly reverts a6385b382e05a614a99e5a5913d8e631823159a2. --- django/db/migrations/operations/models.py | 8 ------- docs/internals/deprecation.txt | 3 --- docs/ref/checks.txt | 6 ------ docs/ref/migration-operations.txt | 7 ------- docs/releases/4.2.txt | 2 -- .../migrations_test_apps/__init__.py | 0 .../index_together_app/__init__.py | 0 .../index_together_app/apps.py | 5 ----- .../migrations/0001_initial.py | 16 -------------- .../index_together_app/migrations/__init__.py | 0 tests/check_framework/test_migrations.py | 21 ------------------- tests/migrations/test_operations.py | 1 - tests/migrations/test_optimizer.py | 3 --- .../test_index_together_deprecation.py | 20 ------------------ 14 files changed, 92 deletions(-) delete mode 100644 tests/check_framework/migrations_test_apps/__init__.py delete mode 100644 tests/check_framework/migrations_test_apps/index_together_app/__init__.py delete mode 100644 tests/check_framework/migrations_test_apps/index_together_app/apps.py delete mode 100644 tests/check_framework/migrations_test_apps/index_together_app/migrations/0001_initial.py delete mode 100644 tests/check_framework/migrations_test_apps/index_together_app/migrations/__init__.py delete mode 100644 tests/model_options/test_index_together_deprecation.py diff --git a/django/db/migrations/operations/models.py b/django/db/migrations/operations/models.py index 91a4e14cb7..75a3b8b030 100644 --- a/django/db/migrations/operations/models.py +++ b/django/db/migrations/operations/models.py @@ -615,14 +615,6 @@ class AlterIndexTogether(AlterTogetherOptionOperation): option_name = "index_together" - system_check_deprecated_details = { - "msg": ( - "AlterIndexTogether is deprecated. Support for it (except in historical " - "migrations) will be removed in Django 5.1." - ), - "id": "migrations.W001", - } - def __init__(self, name, index_together): super().__init__(name, index_together) diff --git a/docs/internals/deprecation.txt b/docs/internals/deprecation.txt index 80597eb95b..a12834c431 100644 --- a/docs/internals/deprecation.txt +++ b/docs/internals/deprecation.txt @@ -19,9 +19,6 @@ details on these changes. * The model's ``Meta.index_together`` option will be removed. -* The ``AlterIndexTogether`` migration operation will be removed. A stub - operation will remain for compatibility with historical migrations. - * The ``length_is`` template filter will be removed. * The ``django.contrib.auth.hashers.SHA1PasswordHasher``, diff --git a/docs/ref/checks.txt b/docs/ref/checks.txt index 8dbada5787..55e4ca64b2 100644 --- a/docs/ref/checks.txt +++ b/docs/ref/checks.txt @@ -397,12 +397,6 @@ Models * **models.W045**: Check constraint ```` contains ``RawSQL()`` expression and won't be validated during the model ``full_clean()``. -Migrations ----------- - -* **migrations.W001**: ``AlterIndexTogether`` is deprecated. Support for it - (except in historical migrations) will be removed in Django 5.1. - Security -------- diff --git a/docs/ref/migration-operations.txt b/docs/ref/migration-operations.txt index b3d8992738..f8bfc4fb6b 100644 --- a/docs/ref/migration-operations.txt +++ b/docs/ref/migration-operations.txt @@ -106,13 +106,6 @@ Changes the model's set of custom indexes (the :attr:`~django.db.models.Options.index_together` option on the ``Meta`` subclass). -.. deprecated:: 4.2 - - ``AlterIndexTogether`` is deprecated in favor of - :class:`~django.db.migrations.operations.AddIndex`, - :class:`~django.db.migrations.operations.RemoveIndex`, and - :class:`~django.db.migrations.operations.RenameIndex` operations. - ``AlterOrderWithRespectTo`` --------------------------- diff --git a/docs/releases/4.2.txt b/docs/releases/4.2.txt index ad061857bf..3b8ae5596c 100644 --- a/docs/releases/4.2.txt +++ b/docs/releases/4.2.txt @@ -319,8 +319,6 @@ Miscellaneous `_ for using Python's :py:mod:`secrets` module to generate passwords. -* The ``AlterIndexTogether`` migration operation is deprecated. - * The ``length_is`` template filter is deprecated in favor of :tfilter:`length` and the ``==`` operator within an :ttag:`{% if %}` tag. For example diff --git a/tests/check_framework/migrations_test_apps/__init__.py b/tests/check_framework/migrations_test_apps/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 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 deleted file mode 100644 index e69de29bb2..0000000000 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 deleted file mode 100644 index 3bb7170897..0000000000 --- a/tests/check_framework/migrations_test_apps/index_together_app/apps.py +++ /dev/null @@ -1,5 +0,0 @@ -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 deleted file mode 100644 index c642ee6c57..0000000000 --- a/tests/check_framework/migrations_test_apps/index_together_app/migrations/0001_initial.py +++ /dev/null @@ -1,16 +0,0 @@ -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 deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/tests/check_framework/test_migrations.py b/tests/check_framework/test_migrations.py index e41a68fa54..0b00690e77 100644 --- a/tests/check_framework/test_migrations.py +++ b/tests/check_framework/test_migrations.py @@ -1,11 +1,7 @@ -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): @@ -54,23 +50,6 @@ 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): diff --git a/tests/migrations/test_operations.py b/tests/migrations/test_operations.py index 8c7edac478..f2edf6ac73 100644 --- a/tests/migrations/test_operations.py +++ b/tests/migrations/test_operations.py @@ -3353,7 +3353,6 @@ class OperationTests(OperationTestBase): definition[2], {"name": "Pony", "index_together": {("pink", "weight")}} ) - # RemovedInDjango51Warning. def test_alter_index_together_remove(self): operation = migrations.AlterIndexTogether("Pony", None) self.assertEqual( diff --git a/tests/migrations/test_optimizer.py b/tests/migrations/test_optimizer.py index 014f291db8..6485009eb4 100644 --- a/tests/migrations/test_optimizer.py +++ b/tests/migrations/test_optimizer.py @@ -211,7 +211,6 @@ class OptimizerTests(SimpleTestCase): migrations.AlterUniqueTogether("Foo", [["a", "b"]]) ) - # RemovedInDjango51Warning. def test_create_alter_index_delete_model(self): self._test_create_alter_foo_delete_model( migrations.AlterIndexTogether("Foo", [["a", "b"]]) @@ -249,7 +248,6 @@ class OptimizerTests(SimpleTestCase): migrations.AlterUniqueTogether("Foo", [["a", "c"]]), ) - # RemovedInDjango51Warning. def test_alter_alter_index_model(self): self._test_alter_alter_model( migrations.AlterIndexTogether("Foo", [["a", "b"]]), @@ -1057,7 +1055,6 @@ class OptimizerTests(SimpleTestCase): migrations.AlterUniqueTogether("Foo", [["a", "b"]]) ) - # RemovedInDjango51Warning. def test_create_alter_index_field(self): self._test_create_alter_foo_field( migrations.AlterIndexTogether("Foo", [["a", "b"]]) diff --git a/tests/model_options/test_index_together_deprecation.py b/tests/model_options/test_index_together_deprecation.py deleted file mode 100644 index 9b5362a924..0000000000 --- a/tests/model_options/test_index_together_deprecation.py +++ /dev/null @@ -1,20 +0,0 @@ -from django.db import models -from django.test import TestCase -from django.utils.deprecation import RemovedInDjango51Warning - - -class IndexTogetherDeprecationTests(TestCase): - def test_warning(self): - msg = ( - "'index_together' is deprecated. Use 'Meta.indexes' in " - "'model_options.MyModel' instead." - ) - with self.assertRaisesMessage(RemovedInDjango51Warning, msg): - - class MyModel(models.Model): - field_1 = models.IntegerField() - field_2 = models.IntegerField() - - class Meta: - app_label = "model_options" - index_together = ["field_1", "field_2"]