django - 在 Django 1.7c2 中运行迁移时出现循环依赖错误

标签 django django-migrations

我一直在 https://docs.djangoproject.com/en/1.7/topics/migrations/ 上阅读有关 django 迁移的信息。 .我还查看了 github 中 1.7.x 分支上的提交,我知道这个问题可能已经解决了。
不幸的是,我在运行迁移时仍然遇到错误。 --fake 选项给出了相同的错误。

我有以下迁移:

“人”应用程序迁移:

user@host$ /manage.py makemigrations people
Migrations for 'people':
0001_initial.py:
- Create model Person
- Create model Committee
- Create model DepartmentGroup
- Add field department_group to person
- Create model MemberType
- Add field member_type to person
- Alter unique_together for person (1 constraint(s))
- Create model PersonCommittee
- Add field committees to committee
- Add field committee to personcommittee
- Add field member to personcommittee
- Alter unique_together for personcommittee (1 constraint(s))
- Create model Role
- Create proxy model PersonArchive

“位置”应用程序迁移:
user@host$ ./manage.py makemigrations locations
Migrations for 'locations':
0001_initial.py:
- Create model Building
- Create model Institution
- Create model InstitutionAddress
- Add field institution to building
- Add field address to institutionaddress
- Add field institution to institutionaddress
- Create model Room
- Alter unique_together for room (1 constraint(s))

现在我运行迁移
./manage.py migrate

这是我得到的错误
django.db.migrations.graph.CircularDependencyError: 
[('people', u'0001_initial'), ('locations', u'0001_initial'), 
('people', u'0001_initial')]

完整的错误可以在以下位置查看:http://pastebin.com/jixK6Ve2

我的问题是 django 代码中是否还有需要修复的内容,请参阅固定票证:https://code.djangoproject.com/ticket/22932 .如果没有,是否可以选择将迁移分为 2 个或更多步骤来避免循环依赖错误?

最佳答案

用户 humitos 指示的步骤来自 https://code.djangoproject.com/ticket/22932#comment:4似乎已经解决了这个问题。

我基本上需要删除可交换的依赖项和冲突的模型,并将它们放入新的空迁移中。

关于django - 在 Django 1.7c2 中运行迁移时出现循环依赖错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25292873/

相关文章:

python - Django Social Auth w/Twitter : HTTP 401 Error (Unauthorized)

python - 如何在链接中传递变量到 Django View

Django 在模板中分隔数千个

Django Migrations 添加默认字段作为模型的函数

django - 尝试在 Django 中创建一个带有外键列表的 PostgreSQL 字段

python - Postgres View 的 Django 模型

python - Django:view如何从url获取多个值?

django - 如何从django-haystack和Elasticsearch中排除无关的搜索结果?

php - Django - 无法进行迁移,MySQL 5.7.19,Py 3.6.2

Django 迁移不会更新我的数据库