Modify

Ticket #244 (closed defect: fixed)

Opened 2 years ago

Last modified 2 years ago

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.

Attachments

Change History

comment:1 Changed 2 years ago by andrew

  • Status changed from new to assigned
  • Milestone set to 0.6.2

comment:2 Changed 2 years ago by andrew

Fixed in [609e43513f28].

comment:3 Changed 2 years ago by andrew

  • Status changed from assigned to closed
  • Resolution set to fixed
View

Add a comment

Modify Ticket

Action
as closed
The resolution will be deleted. Next status will be 'reopened'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.