python - Recovering from a duplicate migration in Django South -


due merging several feature branches project, have following migrations:

0001_initial.py 0002_auto__add_field_userprofile_telephone__add_field_userprofile_timezone.py 0003_auto.py 0004_auto__del_field_organisation_admin.py 0005_auto__add_field_organisation_permitted_domains.py 0005_auto__add_field_userprofile_currency.py 

note have 2 duplicate 0005 migrations. these ran fine, , deployed fine on production system.

$ python manage.py migrate accounts --list                                                                                                                                                              [17:11:42]   accounts   (*) 0001_initial   (*) 0002_auto__add_field_userprofile_telephone__add_field_userprofile_timezone   (*) 0003_auto   (*) 0004_auto__del_field_organisation_admin   (*) 0005_auto__add_field_organisation_permitted_domains   (*) 0005_auto__add_field_userprofile_currency 

my table has correct columns:

$ psql db_my_project=# \d+ accounts_organisation db_my_project=# \d+ accounts_userprofile ... shows currency , permitted_domain, suggesting migrations worked correctly 

however, if try create new migration, south thinks haven't added column' permitted_domains' model:

$ python manage.py schemamigration accounts --auto                                                                                                                                                      [17:16:15]  + added field permitted_domains on accounts.organisation created 0006_auto__add_field_organisation_permitted_domains.py. can apply migration with: ./manage.py migrate accounts 

how fix this?

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

when autodetector runs, compares current models frozen in recent migration on app, , if finds changes, yields 1 or more actions south migration-file-writer.

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

therefore:

in 0005_auto__add_field_organisation_permitted_domains organisation class have field permitted_domains in 0005_auto__add_field_userprofile_currency not. when run:

$ python manage.py schemamigrate accounts --auto 

this compare current state of code against record of fields store in 0005_auto_add_field_userprofile_currency, leading south add field second time.

if copy line 'permitted_domains' field 0005_auto__add_field_organisation_permitted_domains 0005_auto__add_field_userprofile_currency solve problem.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -