Ticket #346 (closed defect: fixed)

Opened 6 years ago

Last modified 6 years ago

Duplicate index creation on foreign keys

Reported by: tommi@… Owned by: andrew
Priority: critical Milestone: 0.7
Component: commands Version: 0.7-pre
Keywords: Cc:


Concerning at least changeset 632:3885e6f4db33, seemed to work with yesterday's trunk.

(Using MySQL) Even with model definition as simple as this:

from django.db import models

class Target(models.Model):

class ProblemModel(models.Model):
    target = models.ForeignKey('Target')

the schemamigration will succeed but migrate will fail, complaining about duplicate key names:

_mysql_exceptions.OperationalError?: (1061, "Duplicate key name 'buggy_problemmodel_target_id'")

Lines 506-507 in south.db.generic.DatabaseOperations?.column_sql seem to cause the problem since the index will be created in the previous foreign key section.

So if you're struggling with your code, comment those lines out. You could end up with missing indices, though.

Used changeset 632:3885e6f4db33,
Django revision 1.2 beta 1 SVN-12403

Change History

comment:1 Changed 6 years ago by andrew

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

This is probably related to the fix I did yesterday for the geometry indexes with the contrib.gis stuff. I'll fix it this afternoon.

comment:2 Changed 6 years ago by andrew

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

Fixed in [d138cb5f8930].

Note: See TracTickets for help on using tickets.