[Django] #25618: Django migration system breaks with unhelpful error message if south migrations accidentally retained

10 views
Skip to first unread message

Django

unread,
Oct 27, 2015, 1:41:26 PM10/27/15
to django-...@googlegroups.com
#25618: Django migration system breaks with unhelpful error message if south
migrations accidentally retained
----------------------------+-------------------------------
Reporter: ryuusenshi | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 1.7
Severity: Normal | Keywords: migrations, south
Triage Stage: Unreviewed | Has patch: 1
Easy pickings: 1 | UI/UX: 0
----------------------------+-------------------------------
For an app that contains both django and south type migrations, the
migration system will become unable to perform any migration task for that
app, and the error message will not be helpful at all (either "Application
labels aren't unique, duplicates: x" - django 1.7, or "table x already
exists" - django 1.8). This happens because the app is treated as both
migrated and unmigrated at the same time.

To reproduce this error, you can clone the repo:
[https://github.com/ryuusenshi/django-south-migrate-bugfix django-south-
bug]. This repo contains a migrations directory with 2 south type
migration in it.

Now run:
{{{
python manage.py makemigrations djsouth
}}}

followed by:
{{{
python manage.py migrate
}}}

What is of particular interest here is that the makemigrations command
created the initial django migration without deleting the other numbered
(south) migrations, thus putting the app into an erroneous state.

Additionally, it is worth noting that in this workflow, step 3 from
[https://docs.djangoproject.com/en/1.7/topics/migrations/#upgrading-from-
south upgrading-from-south] was skipped, so essentially it is user error,
however I believe that the error message should not be entirely unhelpful.

The patch attached can be applied to both django 1.7 and 1.8, since they
are both affected by this. The patch will break the execution of the
migration system at the graph construction phase and report with a helpful
error message.

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

Django

unread,
Oct 27, 2015, 1:41:49 PM10/27/15
to django-...@googlegroups.com
#25618: Django migration system breaks with unhelpful error message if south
migrations accidentally retained
-------------------------------+----------------------------

Reporter: ryuusenshi | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 1.7
Severity: Normal | Resolution:

Keywords: migrations, south | Triage Stage: Unreviewed
Has patch: 1 | Easy pickings: 1
UI/UX: 0 |
-------------------------------+----------------------------
Changes (by ryuusenshi):

* Attachment "django-south-bug-fix.diff" added.

Django

unread,
Oct 27, 2015, 1:45:45 PM10/27/15
to django-...@googlegroups.com
#25618: Django migration system breaks with unhelpful error message if south
migrations accidentally retained
-------------------------------+----------------------------

Reporter: ryuusenshi | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 1.7
Severity: Normal | Resolution:

Keywords: migrations, south | Triage Stage: Unreviewed
Has patch: 1 | Easy pickings: 1
UI/UX: 0 |
-------------------------------+----------------------------
Changes (by ryuusenshi):

* Attachment "django-south-bug-fix.diff" added.


Django

unread,
Oct 27, 2015, 2:30:47 PM10/27/15
to django-...@googlegroups.com
#25618: Django migration system breaks with unhelpful error message if south
migrations accidentally retained
-----------------------------------+------------------------------------

Reporter: ryuusenshi | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 1.7
Severity: Normal | Resolution:
Keywords: migrations, south | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

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

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


Comment:

It's a bit late to add this (in particular, 1.7 is end-of-life Dec. 1 and
is only receiving security updates), but adding to 1.8/1.9 seems okay
since you offered a patch, so I converted it to a
[https://github.com/django/django/pull/5489 pull request]. For 1.10, I
proposed to [https://github.com/django/django/pull/5488 remove detection
of south migrations].

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

Django

unread,
Oct 28, 2015, 9:17:41 AM10/28/15
to django-...@googlegroups.com
#25618: Django migration system breaks with unhelpful error message if south
migrations accidentally retained
-----------------------------------+------------------------------------

Reporter: ryuusenshi | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 1.7
Severity: Normal | Resolution:
Keywords: migrations, south | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-----------------------------------+------------------------------------

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

In [changeset:"c4af8eb366be45420e13a400cc1dcc8fab91c1ad" c4af8eb]:
{{{
#!CommitTicketReference repository=""
revision="c4af8eb366be45420e13a400cc1dcc8fab91c1ad"
Refs #25618 -- Removed detection of south migrations in loader.

It doesn't seem relevant for anyone upgrading to Django 1.10
and beyond.
}}}

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

Django

unread,
Oct 28, 2015, 10:19:34 AM10/28/15
to django-...@googlegroups.com
#25618: Django migration system breaks with unhelpful error message if south
migrations accidentally retained
-----------------------------------+------------------------------------
Reporter: ryuusenshi | Owner: nobody
Type: Bug | Status: closed
Component: Migrations | Version: 1.7
Severity: Normal | Resolution: fixed

Keywords: migrations, south | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-----------------------------------+------------------------------------
Changes (by Tim Graham <timograham@…>):

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


Comment:

In [changeset:"65bff161ffab1310719bdee495d1e9b35f838c31" 65bff16]:
{{{
#!CommitTicketReference repository=""
revision="65bff161ffab1310719bdee495d1e9b35f838c31"
[1.8.x] Fixed #25618 -- Added a helpful error message when Django & south
migrations exist in the same directory.
}}}

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

Django

unread,
Oct 28, 2015, 10:20:15 AM10/28/15
to django-...@googlegroups.com
#25618: Django migration system breaks with unhelpful error message if south
migrations accidentally retained
-----------------------------------+------------------------------------
Reporter: ryuusenshi | Owner: nobody
Type: Bug | Status: closed
Component: Migrations | Version: 1.7

Severity: Normal | Resolution: fixed
Keywords: migrations, south | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-----------------------------------+------------------------------------

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

In [changeset:"774a893d0bf3433571a94cd27883fab61010440a" 774a893]:
{{{
#!CommitTicketReference repository=""
revision="774a893d0bf3433571a94cd27883fab61010440a"
[1.9.x] Fixed #25618 -- Added a helpful error message when Django & south


migrations exist in the same directory.

Forwardport of 65bff161ffab1310719bdee495d1e9b35f838c31 from stable/1.8.x
}}}

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

Django

unread,
Oct 28, 2015, 10:21:52 AM10/28/15
to django-...@googlegroups.com
#25618: Django migration system breaks with unhelpful error message if south
migrations accidentally retained
-----------------------------------+------------------------------------
Reporter: ryuusenshi | Owner: nobody
Type: Bug | Status: closed
Component: Migrations | Version: 1.7

Severity: Normal | Resolution: fixed
Keywords: migrations, south | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-----------------------------------+------------------------------------

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

In [changeset:"e5ab75d2fda8ef2617bc13074206e66c980ca51f" e5ab75d2]:
{{{
#!CommitTicketReference repository=""
revision="e5ab75d2fda8ef2617bc13074206e66c980ca51f"
Refs #25618 -- Forwardported 1.8.6 release note.

Forwardport of 65bff161ffab1310719bdee495d1e9b35f838c31 from stable/1.8.x
}}}

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

Django

unread,
Oct 29, 2015, 7:41:47 AM10/29/15
to django-...@googlegroups.com
#25618: Django migration system breaks with unhelpful error message if south
migrations accidentally retained
-----------------------------------+------------------------------------
Reporter: ryuusenshi | Owner: nobody
Type: Bug | Status: closed
Component: Migrations | Version: 1.7

Severity: Normal | Resolution: fixed
Keywords: migrations, south | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-----------------------------------+------------------------------------

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

In [changeset:"9e7d0d90cc35800cd309d4e0296523220864e884" 9e7d0d9]:
{{{
#!CommitTicketReference repository=""
revision="9e7d0d90cc35800cd309d4e0296523220864e884"
[1.9.x] Fixed #25627, refs #25618 -- Removed detection of south migrations
in loader.

Backport of c4af8eb366be45420e13a400cc1dcc8fab91c1ad from master
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/25618#comment:6>

Django

unread,
Nov 4, 2015, 2:52:39 PM11/4/15
to django-...@googlegroups.com
#25618: Django migration system breaks with unhelpful error message if south
migrations accidentally retained
-----------------------------------+------------------------------------

Reporter: ryuusenshi | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 1.7
Severity: Normal | Resolution:

Keywords: migrations, south | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-----------------------------------+------------------------------------
Changes (by codingjoe):

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


Comment:

The "fix" breaks `django_extensions` and possibly a lot of other packages
that have support for pre django 1.7 versions.

--
Ticket URL: <https://code.djangoproject.com/ticket/25618#comment:7>

Django

unread,
Nov 4, 2015, 3:33:24 PM11/4/15
to django-...@googlegroups.com
#25618: Django migration system breaks with unhelpful error message if south
migrations accidentally retained
-----------------------------------+------------------------------------

Reporter: ryuusenshi | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 1.7
Severity: Normal | Resolution:
Keywords: migrations, south | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-----------------------------------+------------------------------------

Comment (by ryuusenshi):

The problem is actually in the fact that `django-extensions` is using the
`migrations` module to store south migrations and still claims to support
Django 1.4 and later. However, since 1.7 the `migrations` module was
reserved for Django migrations, and even the
[http://south.readthedocs.org/en/latest/releasenotes/1.0.html last
official release of South] instructs developers to move south migrations
to `south_migrations` module.

So, in conclusion, `django-extensions` never really fully supported Django
1.7+.

--
Ticket URL: <https://code.djangoproject.com/ticket/25618#comment:8>

Django

unread,
Nov 4, 2015, 4:00:47 PM11/4/15
to django-...@googlegroups.com
#25618: Django migration system breaks with unhelpful error message if south
migrations accidentally retained
-----------------------------------+------------------------------------

Reporter: ryuusenshi | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 1.7
Severity: Normal | Resolution:
Keywords: migrations, south | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-----------------------------------+------------------------------------
Changes (by ryuusenshi):

* Attachment "django_style_migrations_fix.diff" added.

Django

unread,
Nov 4, 2015, 4:05:57 PM11/4/15
to django-...@googlegroups.com
#25618: Django migration system breaks with unhelpful error message if south
migrations accidentally retained
-----------------------------------+------------------------------------

Reporter: ryuusenshi | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 1.7
Severity: Normal | Resolution:
Keywords: migrations, south | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-----------------------------------+------------------------------------

Comment (by ryuusenshi):

I'm not even sure if this should really be fixed on django's side, but
I've created another
[https://code.djangoproject.com/attachment/ticket/25618/django_style_migrations_fix.diff
patch], just in case.

This patch would make it so that in the case such as `django-extensions`
where south `migrations` module was just left hanging around, against
instructions to be moved, Django would just ignore those migrations.

I will create a pull request later, and let the core developers decide
whether this should be addressed or not.

--
Ticket URL: <https://code.djangoproject.com/ticket/25618#comment:9>

Django

unread,
Nov 4, 2015, 5:25:44 PM11/4/15
to django-...@googlegroups.com
#25618: Django migration system breaks with unhelpful error message if south
migrations accidentally retained
-----------------------------------+------------------------------------

Reporter: ryuusenshi | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 1.7
Severity: Normal | Resolution:
Keywords: migrations, south | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-----------------------------------+------------------------------------
Changes (by tiberius):

* cc: django@… (added)


--
Ticket URL: <https://code.djangoproject.com/ticket/25618#comment:10>

Django

unread,
Nov 4, 2015, 6:01:46 PM11/4/15
to django-...@googlegroups.com
#25618: Django migration system breaks with unhelpful error message if south
migrations accidentally retained
-----------------------------------+------------------------------------

Reporter: ryuusenshi | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 1.7
Severity: Normal | Resolution:
Keywords: migrations, south | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-----------------------------------+------------------------------------

Comment (by ryuusenshi):

@codingjoe, I've created a new [https://github.com/django/django/pull/5548
pull request] to address the problem you reported here.

--
Ticket URL: <https://code.djangoproject.com/ticket/25618#comment:11>

Django

unread,
Nov 10, 2015, 4:19:08 AM11/10/15
to django-...@googlegroups.com
#25618: Django migration system breaks with unhelpful error message if south
migrations accidentally retained
-----------------------------------+------------------------------------

Reporter: ryuusenshi | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 1.7
Severity: Normal | Resolution:
Keywords: migrations, south | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-----------------------------------+------------------------------------

Comment (by nimasmi):

FWIW django-extensions has fixed it internally (https://github.com/django-
extensions/django-
extensions/commit/dbabd69e48e682916e0ffdc7a3567f8fe148ddf3,
https://github.com/django-extensions/django-
extensions/blob/master/CHANGELOG.md#159), but I acknowledge that Django
should expect other third-party apps not to toe the line.

--
Ticket URL: <https://code.djangoproject.com/ticket/25618#comment:12>

Django

unread,
Nov 10, 2015, 10:36:39 AM11/10/15
to django-...@googlegroups.com
#25618: Django migration system breaks with unhelpful error message if south
migrations accidentally retained
-----------------------------------+------------------------------------
Reporter: ryuusenshi | Owner: nobody
Type: Bug | Status: closed
Component: Migrations | Version: 1.7
Severity: Normal | Resolution: fixed

Keywords: migrations, south | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-----------------------------------+------------------------------------
Changes (by Tim Graham <timograham@…>):

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


Comment:

In [changeset:"8c8a6d8a3f869ecc4d72b96ddb4760a1b59d5e62" 8c8a6d8a]:
{{{
#!CommitTicketReference repository=""
revision="8c8a6d8a3f869ecc4d72b96ddb4760a1b59d5e62"
[1.8.x] Fixed #25618 -- Restored migration support for non-upgraded apps.

A non-upgraded app is one that retains South migrations in the
`migrations` module and doesn't introduce Django migrations.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/25618#comment:13>

Django

unread,
Nov 10, 2015, 10:45:03 AM11/10/15
to django-...@googlegroups.com
#25618: Django migration system breaks with unhelpful error message if south
migrations accidentally retained
-----------------------------------+------------------------------------
Reporter: ryuusenshi | Owner: nobody
Type: Bug | Status: closed
Component: Migrations | Version: 1.7

Severity: Normal | Resolution: fixed
Keywords: migrations, south | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-----------------------------------+------------------------------------

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

In [changeset:"dbbae2cead5ca1f15177415d4bfe795d4402be9f" dbbae2c]:
{{{
#!CommitTicketReference repository=""
revision="dbbae2cead5ca1f15177415d4bfe795d4402be9f"
Refs #25618 -- Forwardported 1.8.7 release note.

Forwardport of 8c8a6d8a3f869ecc4d72b96ddb4760a1b59d5e62 from stable/1.8.x
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/25618#comment:14>

Django

unread,
Nov 10, 2015, 10:45:24 AM11/10/15
to django-...@googlegroups.com
#25618: Django migration system breaks with unhelpful error message if south
migrations accidentally retained
-----------------------------------+------------------------------------
Reporter: ryuusenshi | Owner: nobody
Type: Bug | Status: closed
Component: Migrations | Version: 1.7

Severity: Normal | Resolution: fixed
Keywords: migrations, south | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-----------------------------------+------------------------------------

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

In [changeset:"3dcdfcc8d359fa15f62c46e16875082c8a9c28ff" 3dcdfcc8]:
{{{
#!CommitTicketReference repository=""
revision="3dcdfcc8d359fa15f62c46e16875082c8a9c28ff"
[1.9.x] Refs #25618 -- Forwardported 1.8.7 release note.

Forwardport of 8c8a6d8a3f869ecc4d72b96ddb4760a1b59d5e62 from stable/1.8.x
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/25618#comment:15>

Reply all
Reply to author
Forward
0 new messages