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.
I have the following migrations:
'people' app migration:
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
'locations' app migration:
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))
Now I run the migrations with
./manage.py migrate
and this is the error I get
django.db.migrations.graph.CircularDependencyError:
[('people', u'0001_initial'), ('locations', u'0001_initial'),
('people', u'0001_initial')]
The full error can be viewed at: http://pastebin.com/jixK6Ve2
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?
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.
来源:https://stackoverflow.com/questions/25292873/circular-dependency-error-when-running-migrations-in-django-1-7c2