在Django 1.7c2中运行迁移时的循环依赖性错误 [英] Circular dependency error when running migrations in Django 1.7c2

查看:318
本文介绍了在Django 1.7c2中运行迁移时的循环依赖性错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在 https://docs.djangoproject.com/en/1.7/阅读关于django迁移的信息专题/迁移/ 。我还回顾了github中的1.7.x分支的提交,我明白这个问题可能已经解决了。
不幸的是,我仍然在运行我的迁移时收到错误。 --fake选项提供相同的错误。

I have been reading about django migrations at https://docs.djangoproject.com/en/1.7/topics/migrations/. I also reviewed the commits on the 1.7.x branch in github where I understand that this problem may have been solved. Unfortunately I still get the error when running my migrations. The --fake option gives the same error.

我有以下迁移:

'人们的应用迁移:

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

The full error can be viewed at: http://pastebin.com/jixK6Ve2

我的问题是如果django代码中还有一些需要修复的内容,请参阅fixed票: https://code.djangoproject.com/ticket/22932 。如果没有,是否有一个选项可以在两个或多个步骤中拆分迁移以避免循环依赖错误?

My question is if there is still something in the django code that needs to be fixed, see fixed ticket: https://code.djangoproject.com/ticket/22932. If not, is there an option to split the migrations in 2 or more steps to avoid the circular dependency error?

推荐答案

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

The steps indicated by user humitos from https://code.djangoproject.com/ticket/22932#comment:4 seem to have solved the problem.

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

I basically needed to remove the swappable dependency and the conflicting model and put them in a new empty migration.

这篇关于在Django 1.7c2中运行迁移时的循环依赖性错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆