[Django] #23013: Removing unique_together constraint from model fails

16 views
Skip to first unread message

Django

unread,
Jul 13, 2014, 2:42:28 AM7/13/14
to django-...@googlegroups.com
#23013: Removing unique_together constraint from model fails
---------------------------------+----------------------
Reporter: melinath | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 1.7-rc-1
Severity: Release blocker | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+----------------------
This actually fails in two places. In both cases, it is because
`unique_together` is being set to None, and things expect it to be a list.

First, in trying to create the migration.

{{{
# django/django/db/migrations/operations/models.py, line 251
# This fails
return "Alter %s for %s (%s constraint(s))" % (self.option_name,
self.name, len(self.unique_together))

# Should be
return "Alter %s for %s (%s constraint(s))" % (self.option_name,
self.name, len(self.unique_together) if self.unique_together is not None
else 0)
}}}

Second, in trying to *run* the migration (if you fix the first issue or
manually create a migration.

{{{
# django/django/db/migrations/state.py, line 276
# This fails
meta_contents["unique_together"] = list(meta_contents["unique_together"])

# Should be
meta_contents["unique_together"] = list(meta_contents["unique_together"])
if meta_contents["unique_together"] is not None else None
}}}

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

Django

unread,
Jul 13, 2014, 8:36:45 PM7/13/14
to django-...@googlegroups.com
#23013: Removing unique_together constraint from model fails
---------------------------------+------------------------------------

Reporter: melinath | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 1.7-rc-1
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
---------------------------------+------------------------------------
Changes (by timo):

* needs_better_patch: => 0
* has_patch: 0 => 1
* needs_docs: => 0
* needs_tests: => 1
* stage: Unreviewed => Accepted


Comment:

Will try to finish tomorrow if no one beats me to it.

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

Django

unread,
Jul 14, 2014, 7:52:42 AM7/14/14
to django-...@googlegroups.com
#23013: Removing unique_together constraint from model fails
---------------------------------+------------------------------------
Reporter: melinath | Owner: timo
Type: Bug | Status: assigned
Component: Migrations | Version: 1.7-rc-1

Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
---------------------------------+------------------------------------
Changes (by timo):

* owner: nobody => timo
* status: new => assigned


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

Django

unread,
Jul 14, 2014, 9:14:57 AM7/14/14
to django-...@googlegroups.com
#23013: Removing unique_together constraint from model fails
---------------------------------+------------------------------------
Reporter: melinath | Owner: timo
Type: Bug | Status: assigned
Component: Migrations | Version: 1.7-rc-1

Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
---------------------------------+------------------------------------
Changes (by timo):

* needs_tests: 1 => 0


Comment:

[https://github.com/django/django/pull/2915 PR]

--
Ticket URL: <https://code.djangoproject.com/ticket/23013#comment:3>

Django

unread,
Jul 15, 2014, 3:21:53 PM7/15/14
to django-...@googlegroups.com
#23013: Removing unique_together constraint from model fails
---------------------------------+------------------------------------
Reporter: melinath | Owner: timo
Type: Bug | Status: closed
Component: Migrations | Version: 1.7-rc-1
Severity: Release blocker | Resolution: fixed

Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
---------------------------------+------------------------------------
Changes (by Tim Graham <timograham@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"015496539247b24c73b163f279ae8c8d3ccefc4c"]:
{{{
#!CommitTicketReference repository=""
revision="015496539247b24c73b163f279ae8c8d3ccefc4c"
Fixed #23013 -- Fixed removing unique_together/index_together constraints
in migrations.

Thanks melinath for the report.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/23013#comment:4>

Django

unread,
Jul 15, 2014, 3:35:17 PM7/15/14
to django-...@googlegroups.com
#23013: Removing unique_together constraint from model fails
---------------------------------+------------------------------------
Reporter: melinath | Owner: timo
Type: Bug | Status: closed
Component: Migrations | Version: 1.7-rc-1

Severity: Release blocker | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
---------------------------------+------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"01515ebaa45a7facc6b450f3fea77dcdbec85887"]:
{{{
#!CommitTicketReference repository=""
revision="01515ebaa45a7facc6b450f3fea77dcdbec85887"
[1.7.x] Fixed #23013 -- Fixed removing unique_together/index_together
constraints in migrations.

Thanks melinath for the report.

Backport of 0154965392 from master
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/23013#comment:5>

Reply all
Reply to author
Forward
0 new messages