從重複的遷移恢復由於合併幾個特性分支到我的項目,我有以下遷移:在Django南
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
請注意,我有兩個重複0005遷移。這些運行良好,在我的生產系統上部署得很好。
$ 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
我的表有正確的列:
$ psql
db_my_project=# \d+ accounts_organisation
db_my_project=# \d+ accounts_userprofile
... shows currency and permitted_domain, suggesting the migrations worked correctly
但是,如果我嘗試創建一個新的遷移,南認爲我還沒有添加列」 permitted_domains'我的模型:
$ 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. You can now apply this migration with: ./manage.py migrate accounts
我該如何解決這個問題?
對於其他人指的是:不要忘記刪除摺疊的遷移(即,''0005_auto__add_field_organisation_permitted_domains'在這種情況下)來自'south_migrationhistory'表格,否則當你運行'migrate'時你會得到這個錯誤:'我不相信自己;要麼通過擺弄south_migrationhistory表來解決這個問題,要麼將--delete-ghost-migrations傳遞給South,讓它刪除所有這些記錄(這可能不太好)。 –
3cheesewheel
2014-02-13 19:15:24