[Django] #27248: Running migrations one-by-one fails after adding django.contrib.sites to INSTALLED_APPS.

4 views
Skip to first unread message

Django

unread,
Sep 19, 2016, 1:57:27 PM9/19/16
to django-...@googlegroups.com
#27248: Running migrations one-by-one fails after adding django.contrib.sites to
INSTALLED_APPS.
-------------------------------+------------------------------------
Reporter: doctoryes | Owner: nobody
Type: Bug | Status: new
Component: contrib.sites | Version: 1.8
Severity: Normal | Keywords: migrations django_site
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------
An application we've written added django.contrib.sites to its
INSTALLED_APPS. In the same release, other migrations were generated that
needed to be applied. The dependency-ordered migrations list at this point
pre-migration follows:
{{{
migrations:
- [taggit, 0002_auto_20150616_2121]
- [course_metadata, 0017_auto_20160815_2135]
- [course_metadata, 0018_auto_20160815_2252]
- [sites, 0001_initial]
- [django_comments, 0001_initial]
- [django_comments, 0002_update_user_email_field_length]
- [django_comments, 0003_add_submit_date_index]
- [publisher_comments, 0001_initial]
}}}
We then attempted to run these migrations one-by-one via {{{python
./manage.py <app> <migration>}}} commands. (Why? To better record which
migrations succeeded, which one failed, and which migrations remain
unapplied, since this migration process runs in an automated pipeline.)
The first specific app/migration migrate failed with a stack nearly the
same as the one here:

https://code.djangoproject.com/ticket/24524#comment:12

The problem is that the sites code assumed that after being added to
INSTALLED_APPS, a {{{python ./manage.py migrate}}} command would be run to
execute all migrations together - and *then* catch a post-migrate signal
which calls {{{create_default_site}}}. Running individual migrations does
not work when an application is in this state.

It looks like some code is in place to attempt to prevent this error, but
it's either incorrect or not working:

https://github.com/django/django/blob/stable/1.8.x/django/contrib/sites/management.py#L12-L18

The workaround: Issue a {{{python ./manage.py migrate}}} command to exit
this state. However, the workaround shouldn't be necessary.

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

Django

unread,
Sep 19, 2016, 2:24:47 PM9/19/16
to django-...@googlegroups.com
#27248: Running migrations one-by-one fails after adding django.contrib.sites to
INSTALLED_APPS.
-------------------------------------+-------------------------------------
Reporter: doctoryes | Owner: nobody
Type: Bug | Status: closed
Component: contrib.sites | Version: 1.8
Severity: Normal | Resolution: fixed
Keywords: migrations | Triage Stage:
django_site | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

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

* status: new => closed
* needs_docs: => 0
* resolution: => fixed
* needs_tests: => 0
* needs_better_patch: => 0


Comment:

I believe this is fixed in Django 1.10 by
61a16e02702fff4665969388f3b61af8cb1a20ae. If not, please reopen.

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

Reply all
Reply to author
Forward
0 new messages