Hi!
I’m looking for some best practices for running migrations in Django. What I’m used to using is having Post/Pre migrations to be able to release without downtime and not creating multiple releases.
For example, I need to add a field preferred_payment_method
to User
and default it to card
. I’d have the migrations and deploy flow:
- Run migrations marked Pre on current code to add
preferred_payment_method
toUser
and set it to defaultcard
. - Deploy and switch to new code
- Run migrations marked Post to remove the default in database and use the django model instead since that is django best practice
How do I achieve this in one release of my Django application?