A database migration passes in staging. The SQL looks simple, and the deployment pipeline reports success.
Then production requests start timing out.
The migration added one column to a large table. Nothing complicated. But while PostgreSQL was waiting for a lock, application queries started piling up behind it.
This is one of the more frustrating backend problems because the SQL can be correct while the deployment strategy is wrong.
I've worked on backend systems where database changes had to fit around running applications. One lesson worth keeping in mind is that a successful migration isn't just one that changes the schema. It's one that lets the application continue working throughout the transition.
Let's walk through a practical approach using PostgreSQL, including the steps I'd take to introduce a required column without turning a routine deployment into an outage.
1.β¦