2016-11-16 34 views
0

我在幾個月前使用FTP將Django 1.9項目部署到了​​Webfaction。不過,我想開始自動化部署過程,並設法將Webfaction上的現有部署鏈接到我的bitbucket回購。在Django服務器上遷移1.9失敗

我的本地環境仍然正常工作,可以使遷移和遷移沒有錯誤。但是,似乎過去的一些遷移並不完全匹配,所以當我對Webfaction進行git pull時,複製了額外的遷移。現在,我不能運行makemigrations或Webfaction遷移了 - 我得到的錯誤

CommandError: Conflicting migrations detected; multiple leaf nodes in the migration graph: (0016_auto_20161030_1228, 0003_auto_20161030_1638 in locations). To fix them run 'python manage.py makemigrations --merge

如果我運行此命令,我看到如下提示:

Merging locations 
    Branch 0016_auto_20161030_1228 
    - Add field added_by to location 
    - Change managers on location 
    - Add field latlng to location 
    - Add field address to location 
    - Alter field latitude on location 
    - Alter field longitude on location 
    - Alter field country on location 
    Branch 0003_auto_20161030_1638 
    - Add field added_by to location 
    - Change managers on location 
    - Add field address to location 
    - Add field latlng to location 
    - Alter field country on location 
    - Alter field latitude on location 
    - Alter field longitude on location` 

Merging will only work if the operations printed above do not conflict 
with each other (working on different fields or models) 
Do you want to merge these migration branches? [y/N] Please answer yes or no: 

我試圖合併遷移,但然後在嘗試遷移該列已存在後出現錯誤。

服務器上遷移文件:

0001_initial.py 
0001_initial.pyc 
0002_auto_20160416_1046.py 
0002_auto_20160416_1046.pyc 
0002_location_added_by.py 
0002_location_added_by.pyc 
0003_auto_20160416_1050.py 
0003_auto_20160416_1050.pyc 
0003_auto_20161030_1638.py 
0003_auto_20161030_1638.pyc 
0004_remove_location_category.py 
0004_remove_location_category.pyc 
0005_fun_nightlife_restaurant_shop.py 
0005_fun_nightlife_restaurant_shop.pyc 
0006_citycoverimage.py 
0006_citycoverimage.pyc 
0007_auto_20160416_1754.py 
0007_auto_20160416_1754.pyc 
0008_auto_20160416_1803.py 
0008_auto_20160416_1803.pyc 
0009_remove_location_reviews.py 
0009_remove_location_reviews.pyc 
0010_auto_20160422_1920.py 
0010_auto_20160422_1920.pyc 
0011_locationimage.py 
0011_locationimage.pyc 
0012_location_added_by.py 
0012_location_added_by.pyc 
0013_auto_20161029_1857.py 
0013_auto_20161029_1857.pyc 
0014_location_address.py 
0014_location_address.pyc 
0015_auto_20161030_1227.py 
0015_auto_20161030_1227.pyc 
0016_auto_20161030_1228.py 
0016_auto_20161030_1228.pyc 
__init__.py 
__init__.pyc 

當地移民文件:

0001_initial.py 
0001_initial.pyc 
0002_auto_20160228_1159.pyc 
0002_auto_20160416_1046.py 
0002_auto_20160416_1046.pyc 
0002_location_reviews.pyc 
0003_auto_20160416_1050.py 
0003_auto_20160416_1050.pyc 
0003_location_city.pyc 
0004_auto_20160228_1255.pyc 
0004_remove_location_category.py 
0004_remove_location_category.pyc 
0005_auto_20160228_1431.pyc 
0005_fun_nightlife_restaurant_shop.py 
0005_fun_nightlife_restaurant_shop.pyc 
0006_citycoverimage.py 
0006_citycoverimage.pyc 
0006_location_category.pyc 
0007_auto_20160304_2220.pyc 
0007_auto_20160416_1754.py 
0007_auto_20160416_1754.pyc 
0008_auto_20160304_2221.pyc 
0008_auto_20160416_1803.py 
0008_auto_20160416_1803.pyc 
0009_location_country.pyc 
0009_remove_location_reviews.py 
0009_remove_location_reviews.pyc 
0010_auto_20160305_1505.pyc 
0010_auto_20160422_1920.py 
0010_auto_20160422_1920.pyc 
0011_locationimage.py 
0011_locationimage.pyc 
0011_location_reviews.pyc 
0012_location_added_by.py 
0012_location_added_by.pyc 
0013_auto_20161029_1857.py 
0013_auto_20161029_1857.pyc 
0014_location_address.py 
0014_location_address.pyc 
0015_auto_20161030_1227.py 
0015_auto_20161030_1227.pyc 
0016_auto_20161030_1228.py 
0016_auto_20161030_1228.pyc 
__init__.py 
__init__.pyc 

刪除所有服務器遷移文件,做一個git拉那麼我只有本地遷移文件沒有工作。

我已閱讀makemigrations --fake,但沒有完全得到它,不知道這是否會有所幫助。

我知道本地db表(PostgreSQL)與Webfaction(也是PostgreSQL)中的表匹配。

寧願不放棄我的產品。 D b。任何援助非常感謝。

+0

您不應該在服務器上運行makemigrations。這是你在開發機器上做的事情。 –

+0

嗨丹尼爾感謝您的答覆。我現在意識到這是它出錯的地方,用來在服務器上運行makemigrations。有關如何進行的任何建議? – Nick

回答

0

好吧,我解決了這個問題。如果有人跑進了同樣的問題,這對我來說

什麼工作在服務器上:

  1. manage.py dumpdata --exclude auth.permissions --exclude CONTENTTYPES> db.json
  2. 刪除數據庫完全
  3. 翻拍與相同的憑證數據庫
  4. 刪除所有遷移文件(除INIT的.py)
  5. manage.py migra TE
  6. 的git的復位 - 硬頭
  7. manage.py loaddata db.json(需要一段時間)

現在應該工作。只需確保您的回購在開始前是最新的。