qwertysmack
qwertysmack

Reputation: 198

Django; squashmigrations and circular dependencies

I have a Django project with multiple apps, many of which contain lots of migration files. I am attempting to squash these one app at a time using the squashmigrations command, however doing so causes a CircularDepencdyError. The Django docs here advise breaking out one of the keys in the circular dependency to resolve the error, but the error does not specify this level of detail. With thousands of lines of migration code to sift through, I am feeling stuck.

Does anyone have experience of solving this sort of issue or know of some best practices or tips on what to look for?

Upvotes: 1

Views: 880

Answers (1)

qwertysmack
qwertysmack

Reputation: 198

As recommended by Sebastian, the fix to this circular dependency mess:

  • delete migration files from project directory
  • remove migration entries from the django_migrations database table
  • run makemigrations - Django creates new migration files
  • run migrate --fake as you should already have the tables in the database

After doing this, I was able to get manage.py test working like a charm.

Upvotes: 3

Related Questions