Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#27826 closed Uncategorized (duplicate)

Django migration can not find existing constraint

Reported by: Michal Čihař Owned by: nobody
Component: Uncategorized Version: 1.10
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


I've a project with long history. The databases were originally migrated by South and then it has moved to Django migrations.

Now when I've made changes to unique_together constraint, I got migration failure:

ValueError: Found wrong number (0) of constraints for trans_check(contentsum, project_id, language_id, check)

This seems to be caused by the constraing being created in different order in past. I think it has been created by South, but I'm not 100% sure. But anyway I've ended up with half applied migration what is not really a pleasant state.

I've fixed this for me by comparing fields as set not as lists (see attached patch), what is certainly okay for unique constraints, but is probably bad idea for general indexes.

Attachments (1)

columns-ordering.patch (1.1 KB ) - added by Michal Čihař 7 years ago.
workaround patch

Download all attachments as: .zip

Change History (3)

by Michal Čihař, 7 years ago

Attachment: columns-ordering.patch added

workaround patch

comment:1 by Tim Graham, 7 years ago

Resolution: duplicate
Status: newclosed

This looks like a duplicate of #23906. The conclusion there is that you must fix your database. Django ignoring the order of columns in an index isn't correct.

comment:2 by Michal Čihař, 7 years ago

Okay, the thing is that the database has been created by Django this way...

Note: See TracTickets for help on using tickets.
Back to Top