Remember that problem I had
writing migration code where the whole site went down? Turns out I
could have fixed that in advance by just following best practices for
There are several libraries meant to help you follow migration best
practices. Two of them are “Good
Migrations” and “Strong
Good Migrations is basically “don’t use models in your migrations.”
It’s true, don’t. Most people already don’t, but Good Migrations
Strong Migrations is “only use migrations that can run with no
downtime and not screw anything up.” This may cramp your style a
little more since you can’t do things like change the type of a
column. There’s no safe way to do it, so Strong Migrations stops you.
You can learn a little more about why to be careful with these
things from No More Lost
Data, my book on migrations.
You can also learn more about the
whys of migrations with no downtime here and in the book.