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 migrations.

There are several libraries meant to help you follow migration best practices. Two of them are “Good Migrations” and “Strong Migrations”.

Good Migrations is basically “don’t use models in your migrations.” It’s true, don’t. Most people already don’t, but Good Migrations enforces it.

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 could once learn a little more about why to be careful with these things from No More Lost Data, my book on migrations - I’ve added most of its contents to my blog over time.

You can also learn more about the whys of migrations with no downtime here and in the book.