Adding a new column is one of the most common schema changes, yet it can be the most dangerous when data volumes scale. A careless migration can lock tables, block writes, and halt production traffic. A well-planned one can ship to production with zero downtime.
First, know the table’s size. Small tables allow instant writes. Large ones demand online migrations. In PostgreSQL, ALTER TABLE ADD COLUMN is fast if the column has no default. Adding a column with a default value rewrites the table. On MySQL, ALTER TABLE often locks the table unless you use ALGORITHM=INPLACE or ONLINE.
Never assume instant execution. Test against realistic data. Benchmark on staging with production-sized datasets. Use migrations that avoid full table rewrites. For example, add the column as nullable with no default. Then backfill in small batches. Finally, apply the default and NOT NULL constraints. This pattern keeps availability high while preserving data integrity.