Adding a new column is one of the most common schema changes, but poor execution can bring down production systems. Latency spikes. Locks pile up. Users wait. To do it right, you need speed, safety, and a plan.
First, define why the column exists. Know its type, constraints, defaults, and how it integrates with existing queries. Avoid unnecessary nullables. Enforce integrity from the start.
Second, choose the migration strategy. In small datasets, a simple ALTER TABLE ADD COLUMN works. In large datasets, migrations must be online. Batch updates, backfills, and shadow columns can prevent downtime. Tools like pt-online-schema-change or native database online DDL features are worth mastering.
Third, deploy in phases. Add the column empty. Deploy code that writes to both the old and new columns. Backfill data in controlled batches. Finally, switch reads to the new column, then remove old columns if needed.