3 ms·
In my opinion, this is one of the major unsolved (or under-solved) issues in web development. You have to write and test migrations, and then you have to make s
by smt88 11y ago
In my opinion, this is one of the major unsolved (or under-solved) issues in web development. You have to write and test migrations, and then you have to make sure the migrations are tied to your deployment/rollback process.
If there's a service/tool that automates a lot of this or makes it safer, I'd be really happy to learn about it!
- UK-AL 11y agoWhen I used to use django ages ago, there used to be Django south. I think its built in now.
- metachris 11y agoYes, its built in now: https://docs.djangoproject.com/en/1.8/topics/migrations/ https://docs.djangoproject.com/en/1.8/topics/migrations/ Of course a database rollback may loose information from any newly created fields.
- jeffasinger 11y agoSo if you're aiming for zero downtime rollbacks with Django, here's how adding a new field to a model might work: 1) Add a Migration that adds the new field, but allows null. Deploy. 2) Add the field to the model. Also make sure it sets it's default on write. Deploy. 3) Execute a background task to set the field to whatever it's default value should be. 4) Add migrations to enforce integrity and add indexes. Deploy. 5) Actually deploy code that needs the new field. Yes, this is super annoying, no, most people don't do this. Separating out #1 and #2 means you can always roll back all the way to right after #1 without losing any data. An extra, nullable field on a model with no indices on it shouldn't hurt anything.
- micah_chatt 11y agoTotally agree. I've been advocating this for months but the ease/simplicity of simply restarting the server with new code has won out for now.