The database table was perfect until the product team asked for one more field. You need a new column. Fast.
Adding a new column sounds trivial, but the wrong approach can block queries, lock tables, and crash performance under load. This guide covers how to add a new column safely in production databases without downtime, data loss, or schema drift.
First, plan the schema change. Document the name, data type, nullability, and default value for the new column. Avoid implicit type conversions that may rewrite the entire table. If working with large datasets, run the schema change in a transaction or use an online DDL tool such as pt-online-schema-change or native online ALTER TABLE features.
Second, handle the default value carefully. Setting a default on a new column can cause the database to backfill existing rows. On massive tables, this can cause long-running locks. Instead, add the column as nullable, deploy, and backfill in controlled batches. After backfill, set the default and enforce NOT NULL if needed.