How to squash recent Django migrations?

python manage.py squashmigrations <appname> <squashfrom> <squashto>

python manage.py help squashmigrations

https://docs.djangoproject.com/en/dev/topics/migrations/#migration-squashing

This will give you more granular control over which migrations to squash, and let you keep a cleaner commit history. Deleting + recreating all migrations may cause other issues such as circular dependencies depending on how models are constructed.


You can just delete the migration files and run makemigrations again. If you have a dev deployment that uses these, you should migrate back to the one before the first one you delete.

Also, it's probably a good idea to commit your code first, in case something goes wrong.

Also:

The slight complication with this is that if there's custom RunPython code, it won't be included in the new migration created by makemigrations