diff --git a/tests/indexes/models.py b/tests/indexes/models.py index f7fcb6175c1..6f6f82bbcb3 100644 --- a/tests/indexes/models.py +++ b/tests/indexes/models.py @@ -38,9 +38,7 @@ class Article(models.Model): ) class Meta: - index_together = [ - ["headline", "pub_date"], - ] + indexes = [models.Index(fields=["headline", "pub_date"])] class IndexedArticle(models.Model): diff --git a/tests/indexes/tests.py b/tests/indexes/tests.py index 11f72850f3f..fb7796ddf82 100644 --- a/tests/indexes/tests.py +++ b/tests/indexes/tests.py @@ -68,17 +68,13 @@ class SchemaIndexesTests(TestCase): ) self.assertEqual(index_name, expected[connection.vendor]) - def test_index_together(self): + def test_quoted_index_name(self): editor = connection.schema_editor() index_sql = [str(statement) for statement in editor._model_indexes_sql(Article)] self.assertEqual(len(index_sql), 1) - # Ensure the index name is properly quoted + # Ensure the index name is properly quoted. self.assertIn( - connection.ops.quote_name( - editor._create_index_name( - Article._meta.db_table, ["headline", "pub_date"], suffix="_idx" - ) - ), + connection.ops.quote_name(Article._meta.indexes[0].name), index_sql[0], ) diff --git a/tests/introspection/models.py b/tests/introspection/models.py index 6381e3481c0..31c1b0de80f 100644 --- a/tests/introspection/models.py +++ b/tests/introspection/models.py @@ -41,9 +41,9 @@ class Article(models.Model): class Meta: ordering = ("headline",) - index_together = [ - ["headline", "pub_date"], - ["headline", "response_to", "pub_date", "reporter"], + indexes = [ + models.Index(fields=["headline", "pub_date"]), + models.Index(fields=["headline", "response_to", "pub_date", "reporter"]), ]