In our django project we had over 900 migrations and they were slowing down our tests. Due to complex interdependencies between apps, we decided that squashing wasn't a real option, so we wanted to reset them. However we have a couple of 3rd party apps as well (celery etc.) with their own migrations. After running python manage.py shell -c "from django.db import connection; cursor = connection.cursor(); cursor.execute(\"DELETE FROM django_migrations WHERE app IN ('api', 'user');\")"
and makemigrations
we are now trying to apply the migrations with --fake-initial
. We are now getting the error
django.db.migrations.exceptions.InconsistentMigrationHistory: Migration admin.0001_initial is applied before its dependency user.0001_initial on database 'default'.
which makes sense as the database currently "thinks" that it has celery, admin etc. installed, but not user (even though it has). How could we work around this issue? Also we can't loose any data, otherwise I would just delete the migrations for this as well or reset the entire database.