Adding a new column in a production database is deceptively simple. Done right, it is a non‑event. Done wrong, it can lock tables, stall queries, or even trigger downtime. The process depends on engine specifics—PostgreSQL, MySQL, and cloud databases all handle it differently—but the principles remain constant: minimize lock time, preserve backward compatibility, and roll out in phases.
First, assess the size of the table. On large datasets, a raw ALTER TABLE ADD COLUMN can block writes for minutes or hours. Most teams now use non‑blocking schema migration tools or online DDL operations, which allow new columns to be added without interrupting queries. PostgreSQL offers ADD COLUMN fast when a default is NULL, because it only updates metadata. MySQL with InnoDB can add certain columns instantly starting from version 11.x variants in some managed providers.
Second, never retroactively populate data in the same migration as the column creation. Create the new column with a safe default, deploy code that writes to both old and new fields, then backfill asynchronously in small batches. This reduces performance impact and avoids long‑running locks.