From 4e8b167e4d0817b6ae93be8ad97b31bf203698d8 Mon Sep 17 00:00:00 2001 From: Tim Graham Date: Mon, 2 Mar 2015 12:48:30 -0500 Subject: [PATCH] Fixed MySQL build failure introduced by refs #24390. Added table_name back to _create_index_sql() to prevent duplicate index names on MySQL. --- django/db/backends/base/schema.py | 2 +- tests/indexes/tests.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/django/db/backends/base/schema.py b/django/db/backends/base/schema.py index 96c7b4b7b8..239af12446 100644 --- a/django/db/backends/base/schema.py +++ b/django/db/backends/base/schema.py @@ -798,7 +798,7 @@ class BaseDatabaseSchemaEditor(object): ) # Else generate the name for the index using a different algorithm table_name = model._meta.db_table.replace('"', '').replace('.', '_') - index_unique_name = '_%s' % self._digest(*column_names) + index_unique_name = '_%s' % self._digest(table_name, *column_names) max_length = self.connection.ops.max_name_length() or 200 # If the index name is too long, truncate it index_name = ('%s_%s%s%s' % ( diff --git a/tests/indexes/tests.py b/tests/indexes/tests.py index 749d6081fc..7d4b866bcf 100644 --- a/tests/indexes/tests.py +++ b/tests/indexes/tests.py @@ -21,7 +21,7 @@ class SchemaIndexesTests(TestCase): column_names=("column1", "column2", "column3"), suffix="123", ) - self.assertEqual(index_name, "indexes_article_column1_856fe518123") + self.assertEqual(index_name, "indexes_article_column1_6bd61f85123") def test_index_together(self): editor = connection.schema_editor()