The migration hit production. Logs lit up with warnings. We needed a new column, and we needed it fast.
Adding a new column to a live database is simple if you plan it. Without planning, it can slow queries, lock tables, or break deployments. The risk grows when the table is huge or serves critical paths.
Start by defining the new column clearly. Decide the data type, nullability, and default. Avoid adding heavy defaults that rewrite the entire table. In PostgreSQL, for example, adding a nullable column without a default is near-instant, even for billions of rows.
Write your migration as an additive change. Always ensure it can be rolled forward if partially applied. Tools like ALTER TABLE make it tempting to do everything at once, but schema changes and data backfills should be separate steps. First, create the new column. Deploy code that writes to both the old and new fields. Only after validation should you drop the old column.