Reputation: 421
I had 10 migrations and I wanted to keep them in one file . So I squash them using ./manage.py squashmigrations accounts
. Now I had 11 files including init and squash file. so I deleted 9 other files and kept init and squash and run migration
and migrate
.
Now want to ask Is this proper way ? and I have another app with same scenario should I do same to that ?
Upvotes: 3
Views: 4160
Reputation: 94
Yes that's basically the way to do it :) Django has a great documentation about how to squash migrations and the appropriate workflow. See https://docs.djangoproject.com/en/3.1/topics/migrations/#migration-squashing
In short,
But additionally, you should
replaces
attribute inside of the squash migration, so that it is considered as a plain migration (and not a squash migration anymore)Then you're done and you can repeat the process for other apps, the same one again once more migrations accumulated again.
Upvotes: 4