0

I was trying to remove on my dev machine old migration files with

manage.py myapp zero

But it failed at some point and I messed up. I have a project with ~1000 migration files. Unfortunately I have no backups for my dev sql database. (I have to build everything from scretch)

But on my prodiction system I have also this ~1000 migration files and was wondering if it is possible to delete all migration files and just use the last state. So that each migrations folder has only one migration file left.

Is this possible? This would save my life ...

EDIT: I ended up using this: https://docs.djangoproject.com/en/4.0/topics/migrations/#migration-squashing

Philipp S.
  • 827
  • 17
  • 41
  • You can delete the migrations in your local app, then send to the server. This will remove the migration files. Pay attention and test on your machine the "makemigrations" may occur inconsistencies between the databases (local/server). Save migration files to have a backup in case something goes wrong. I don't know if this is the best practice – Luiz Henrique Rochelle Jul 07 '22 at 22:13
  • 1
    Take a look at squashing migrations https://docs.djangoproject.com/en/4.0/topics/migrations/#migration-squashing – Iain Shelvington Jul 07 '22 at 22:14
  • Does this answer your question? [How to reset migrations in Django 1.7](https://stackoverflow.com/questions/29253399/how-to-reset-migrations-in-django-1-7) – SvenTUM Jul 07 '22 at 22:23

0 Answers0