8 min
Writing Better Postgres Migrations
Most migration pain is self-inflicted. A few small habits will save you a thousand-line revert at midnight.
Migrations are one of those things every backend engineer ends up doing, and most of us learn the hard way.
A few habits I've ended up with: never combine schema and data changes in one migration; never assume the migration runs against an empty table; always write the down step, even if you'll never use it; and always test against a snapshot of production-like data.
It's slower up front. It saves you the kind of midnight revert that scars an engineer for years.
#PostgreSQL#Backend#Migrations