Here are the steps (for whoever runs into this problem):
- Empty the django_migrations: table:
delete from django_migrations;
- For every app, delete its migrations folder:
rm -rf <app>/migrations/
find . -path "*/migrations/*.py" -not -name "__init__.py" -delete find . -path "*/migrations/*.pyc" -delete
- Reset the migrations for the "built-in" apps:
python manage.py migrate --fake
- For each app run:
python manage.py makemigrations <app>
. Take care of dependencies (models with ForeignKey's should run after their parent model). - Finally:
python manage.py migrate --fake-initial
After that I ran the last command without the --fake-initial flag, just to make sure.
Now everything works and I can use the migrations system normally.
Update for Django >= 1.9 users:
I had this scenario again with a Django 1.9.4, and step 5 failed.
All we have to do is replace --fake-initial
with --fake
to make it work.