I have a Django app that I'm planning on hosting via Azure web-apps. I've seen that Azure offer the option to deploy via different deployment-slots, and would like to incorporate this into my deployment process, as this is by far the most stressful event - deploying to production for my client.
However, I'm a bit unsure on how to do this when I'm going to do migrations to the production database. From my understanding you can compose a "warmup-script" to handle this sorts of things, but I'm not sure on how to actually write it.
I want the startup-script to make the migrations, if they are successful, everything is fine and dandy and the slot 2 should be swapped to the production slot. However, if the migrations fail, I want to roll-back to the previous migrations and not do the swap for the code-base with slot 2 and production, but instead be able to look at the logs and see what was resulting in that the migration failed.
By this process, the downtime on the client-side would be minimised, as I only would stop the server for "maintenance" for a short while, when trying to do the migrations to the production database, and if they would fail, I would simply reverse them and start-up (remove the maintenance message) the production server again (without any migrations done) and be able to debug on my own without causing any downtime in production.
I've made an animated GIF to illustrate how I imagine the process, I've also attached a PDF if you want to go trough each step.