1
0
mirror of https://github.com/django/django.git synced 2024-12-22 17:16:24 +00:00

Fixed MySQL build failure introduced by refs #24390.

Added table_name back to _create_index_sql() to prevent
duplicate index names on MySQL.
This commit is contained in:
Tim Graham 2015-03-02 12:48:30 -05:00
parent fde4857fb8
commit 4e8b167e4d
2 changed files with 2 additions and 2 deletions

View File

@ -798,7 +798,7 @@ class BaseDatabaseSchemaEditor(object):
) )
# Else generate the name for the index using a different algorithm # Else generate the name for the index using a different algorithm
table_name = model._meta.db_table.replace('"', '').replace('.', '_') 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 max_length = self.connection.ops.max_name_length() or 200
# If the index name is too long, truncate it # If the index name is too long, truncate it
index_name = ('%s_%s%s%s' % ( index_name = ('%s_%s%s%s' % (

View File

@ -21,7 +21,7 @@ class SchemaIndexesTests(TestCase):
column_names=("column1", "column2", "column3"), column_names=("column1", "column2", "column3"),
suffix="123", suffix="123",
) )
self.assertEqual(index_name, "indexes_article_column1_856fe518123") self.assertEqual(index_name, "indexes_article_column1_6bd61f85123")
def test_index_together(self): def test_index_together(self):
editor = connection.schema_editor() editor = connection.schema_editor()