I've got a Django app with a lot of out-of-date migrations. I'd like to remove the old migrations and start fresh.
The app has 14 different "migrations" folders.
Here is what a few of them look like:
Is it safe to remove all the contents from each of these folders? Or, do I have to make sure to only remove some of the files -- and if so which files?
You should never just delete migrations before unapplying them, or it will be a nightmare when you want to apply new migrations.
To unapply migrations you should do the following:
Use the python manage.py migrate your_app_name XXXX
in case you want to unapply migrations after the XXXX migration. Otherwise use python manage.py migrate your_app_name zero
to completely unapply all migrations.
Remove the .pyc
files under /migrations/_pycache_/ that you have unapplied.
Remove the .py
files under migrations/ that you have unapplied.
Now you can create new migrations without any headaches.
If what you're looking for is to squash all the migrations into one, do the steps above removing all migrations and then run python manage.py makemigrations your_app_name
to create a single migration file. After that just run python manage.py migrate your_app_name
and you're done.