Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django squash or eliminate migrations on production

I have an app on production. It has 251 migrations that take too much time when I run the tests, it is making development really slow. I need to do something about this and I'd like an advice. Is it recommendable to squash the 251 migrations? what if I erase then and then just fake initial? of course, I can't lose or change the database, it is on production. Thanks a lot for your help.

like image 496
Alejandro Veintimilla Avatar asked Oct 19 '25 14:10

Alejandro Veintimilla


1 Answers

You can try to squash them, but you will probably run into the CircularDependencyError mentioned here: https://docs.djangoproject.com/en/1.11/topics/migrations/#squashing-migrations

Another option is to (make sure your database is backed up) remove all migration files, remove the data in the migrations table, make migrations again, migrate --with --fake-initial and hope everything still works -- obviously, try this in a development environment first, followed by a staging instance identical to your production server.

like image 189
Tom Carrick Avatar answered Oct 22 '25 04:10

Tom Carrick



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!