Adding a new column to a database table is simple in syntax, dangerous in practice. An ALTER TABLE can block writes, lock rows, or spike CPU if done without care. On high-traffic systems, a poorly executed change can cascade into outages.
Start with impact analysis. Check table size, indexes, and query frequency. Determine if the new column will be nullable, have defaults, or require backfilling. Non-null with a default can trigger a rewrite of the table on some engines. On PostgreSQL, adding a nullable column is instant. Adding one with a default value is not. MySQL versions before 8.0.12 can lock the entire table for such changes.
For zero-downtime migrations, break the operation into phases. First, add the column as nullable without a default. Then backfill in small batches, using worker jobs to avoid write amplification. Once complete, enforce constraints and add indexes in separate steps. Each phase should be monitored with metrics on lock times, query latency, and replication lag.