Adding a new column is one of the most common schema changes, but it’s also one of the most dangerous in production if you handle it carelessly. The wrong migration can lock tables, block writes, and trigger downtime. Done right, it becomes a zero-downtime deployment that ships in seconds.
Start by defining the purpose of the new column. Is it a nullable data store for temporary fields, or a non-null value essential to every row? Nullable columns can be added without rewriting existing data. Non-null columns require defaults and may need backfill routines to avoid performance issues.
Direct ALTER TABLE ... ADD COLUMN commands work fine on small datasets. At scale, they can block operations. Use online schema change tools like gh-ost or pt-online-schema-change for large production tables. These tools create a shadow table, copy data incrementally, and swap atomically.
If the new column needs an index, avoid adding it in the same migration. Split schema changes into separate deploy steps to reduce lock time and simplify rollbacks. Migrate column creation first, deploy code that writes to it, backfill in controlled batches, and only then add indexes.