Adding a new column to a database sounds simple. It isn’t, if you care about uptime, data integrity, and performance. A sloppy migration can lock tables, block writes, and trigger a cascade of failed requests. The right approach depends on the data store, volume, and your zero-downtime requirements.
In SQL databases, use ALTER TABLE with caution. For large tables, default clauses or foreign key constraints can turn this into a full table rewrite. Break the process into two steps: first add the nullable column without defaults, then backfill in controlled batches, and set constraints afterward. This avoids table locks and reduces pressure on replicas.
In Postgres, ALTER TABLE ... ADD COLUMN for a nullable field is fast, but adding DEFAULT now() will rewrite every row. MySQL behaves differently: ALTER TABLE copies the table in many cases, tanking performance. For MySQL 8+, use ALGORITHM=INPLACE or ALGORITHM=INSTANT when possible to skip the copy. Always check the execution plan before production runs.