The database table sits in production, untouched for months, until the morning you need a new column. The change must ship fast. The app cannot break. Data must stay consistent.
A new column in a relational database looks simple, but the details decide whether your migration takes seconds or blocks traffic for hours. The schema change will lock writes unless you run it with care. Even small mistakes compound at scale.
Start with your table schema. Check the engine, indexes, and row count. Adding a nullable column with no default is often instant. Adding a column with a default value on a large table can rewrite the full dataset — a dangerous move in production. In Postgres, use ALTER TABLE … ADD COLUMN with NULL allowed, then backfill data in batches. In MySQL, test the operation on a staging dataset first to see if it’s online.