[Django] #27826: Django migration can not find existing constraint

20 views
Skip to first unread message

Django

unread,
Feb 10, 2017, 10:04:15 AM2/10/17
to django-...@googlegroups.com
#27826: Django migration can not find existing constraint
-----------------------------------------+------------------------
Reporter: Michal Čihař | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 1.10
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-----------------------------------------+------------------------
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.

--
Ticket URL: <https://code.djangoproject.com/ticket/27826>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Feb 10, 2017, 10:04:29 AM2/10/17
to django-...@googlegroups.com
#27826: Django migration can not find existing constraint
-------------------------------+--------------------------------------

Reporter: Michal Čihař | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 1.10
Severity: Normal | Resolution:

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by Michal Čihař):

* Attachment "columns-ordering.patch" added.

workaround patch

Django

unread,
Feb 10, 2017, 12:35:10 PM2/10/17
to django-...@googlegroups.com
#27826: Django migration can not find existing constraint
-------------------------------+--------------------------------------

Reporter: Michal Čihař | Owner: nobody
Type: Uncategorized | Status: closed
Component: Uncategorized | Version: 1.10
Severity: Normal | Resolution: duplicate

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by Tim Graham):

* status: new => closed
* resolution: => duplicate


Comment:

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.

--
Ticket URL: <https://code.djangoproject.com/ticket/27826#comment:1>

Django

unread,
Feb 10, 2017, 2:38:38 PM2/10/17
to django-...@googlegroups.com
#27826: Django migration can not find existing constraint
-------------------------------+--------------------------------------

Reporter: Michal Čihař | Owner: nobody
Type: Uncategorized | Status: closed
Component: Uncategorized | Version: 1.10
Severity: Normal | Resolution: duplicate

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------

Comment (by Michal Čihař):

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

--
Ticket URL: <https://code.djangoproject.com/ticket/27826#comment:2>

Reply all
Reply to author
Forward
0 new messages