[Django]-Recovering from a duplicate migration in Django South

3👍

From the docs: http://south.readthedocs.org/en/0.7.6/autodetector.html

When the autodetector runs, it compares your current models with those
frozen in your most recent migration on the app, and if it finds any
changes, yields one or more Actions to the South
migration-file-writer.

The migrations keep a frozen version of the fields within the model in a dict.

Therefore:

In 0005_auto__add_field_organisation_permitted_domains the Organisation class will have a field permitted_domains but in 0005_auto__add_field_userprofile_currency it will not. When you run:

$ python manage.py schemamigrate accounts --auto

this will compare the current state of the code against the record of the fields store in 0005_auto_add_field_userprofile_currency, thus leading south to add the field for a second time.

If you copy the line for the ‘permitted_domains’ field from 0005_auto__add_field_organisation_permitted_domains to 0005_auto__add_field_userprofile_currency this will solve your problem.

2👍

It is a very specific problem, I hope this helps, do the following:

1) Rename this file: 0005_auto__add_field_organisation_permitted_domains to 0006_auto__add_field_organisation_permitted_domains

2) Rename the number of your recently migration file from 0006 to 0007

3) Issue the command python manage.py migrate account 0006 --fake to deceive south.

4) Issue the command python manage.py migrate account 0007

That might get the south engine in sycn again with your application

Hope this helps!

Leave a comment