The database was slow, and the logs pointed to one problem: a missing new column. Adding a column sounds simple, but doing it right can mean the difference between a clean deployment and hours of downtime.
A new column in a relational database changes the shape of your data. It can give your application new capabilities, unlock new indexes, or introduce serious migration headaches. The key is to add it without breaking production or corrupting existing rows.
Plan the schema change before touching the database. Review how the new column will store data: type, nullability, default values. In PostgreSQL or MySQL, adding a NOT NULL column with no default will block until it rewrites every row. On large tables, this can lock writes for minutes or hours. Use nullable columns or safe defaults to avoid long locks.
Backfill in stages. First, add the new column in a non-blocking migration. Then, populate the data in small batches using background jobs or scheduled tasks. Monitor query performance. Add indexes only after the column is fully populated to prevent write slowdowns.