Ticket #244 (closed defect: fixed)
South needs to be smarter about creating long index names.
| Reported by: | screeley | Owned by: | andrew |
|---|---|---|---|
| Priority: | major | Milestone: | 0.6.2 |
| Component: | commands | Version: | 0.6 |
| Keywords: | Cc: | sean@… |
Description
When a table has a very long name, South blindly truncates the index name for a column. This creates indexes with the same name and the db crys. In south.db.generic.DatabaseOperations?.create_index_name the function should be something like this:
def create_index_name(self, table_name, column_names):
"""
Generate a unique name for the index
"""
index_unique_name =
if len(column_names) > 0:
index_unique_name = '_%x' % abs(hash((table_name, ','.join(column_names))))
index_name = ('%s_%s%s' % (table_name, column_names[0], index_unique_name))
if len(index_name) > self.max_index_name_length:
part = ('_%s%s' % (column_names[0], index_unique_name))
index_name = '%s%s' % (table_name[:(self.max_index_name_length-len(part))], part)
return index_name
It keeps the important parts i.e. column name and unique and kills part of the table name.
