【发布时间】:2017-03-30 07:38:06
【问题描述】:
几个月前,我使用 FTP 将我的 Django 1.9 项目部署到了 Webfaction。但是,我想开始自动化部署过程,因此设法将我在 Webfaction 上的现有部署链接到我的 bitbucket 存储库。
我的本地环境仍然可以正常工作,可以进行迁移和迁移而不会出错。然而,过去的一些迁移似乎并不完全匹配,因此当我在 Webfaction 上执行 git pull 时,复制了额外的迁移。现在我无法再在 Webfaction 上运行 makemigrations 或 migrate - 我收到错误
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 pull 所以我只有本地迁移文件不起作用。
我已经阅读了关于 makemigrations --fake 的内容,但没有完全理解,并且不确定这是否会有所帮助。
我知道本地数据库表(PostgreSQL)与 Webfaction 中的表(也是 PostgreSQL)相匹配。
不想放弃我的 Prod。 D b。非常感谢任何帮助。
【问题讨论】:
-
您根本不应该在服务器上运行 makemigrations。那是你在你的开发机器上做的事情。
-
您好丹尼尔,感谢您的回复。我现在意识到这是出了问题的地方,就像在服务器上运行 makemigrations 一样。关于如何进行的任何建议?
标签: django