Ticket #1049 (closed defect: duplicate)

Opened 4 years ago

Last modified 2 years ago

unique_together ordering

Reported by: George Lund <glund@…> Owned by: andrew
Priority: major Milestone: 1.0
Component: commands Version: unknown
Keywords: Cc:


I am trying to add a unique_together constraint to a table.

The fields are listed in specific order, because the index that is created will perform properly only if the fields are in that order. So South needs to respect the order given in each tuple.

The fields are coming out in the right order in the freezer, so it must be something after that I guess (changes.py?).

Change History

comment:1 Changed 4 years ago by andrew

  • Status changed from new to accepted
  • Milestone set to 1.0

Hmm, I'm not aware of anything that changes the ordering, but I haven't looked in there
for a while.

In the meantime, just change the ordering yourself in the migration file.

comment:2 Changed 3 years ago by leftmoose <leftmoose@…>

i'm seeing a problem which is probably related. see e.g. sentry



(the order of the fields in unique_together is reversed when the command to drop the index is generated)

at least for sqlite, this meant that the old index is left in the db

looks like the culprit may be in changes.py:

old_unique_together = map(set, old_unique_together)
new_unique_together = map(set, new_unique_together)

comment:3 Changed 2 years ago by Mike Fogel <mike@…>

This is duplicated by #1273, which has been resolved.

comment:4 Changed 2 years ago by andrew

  • Status changed from accepted to closed
  • Resolution set to duplicate
Note: See TracTickets for help on using tickets.