Adding a new column in a production database sounds simple. It isn’t. Done wrong, it can lock tables, block writes, or flood logs with errors. Done right, it becomes invisible—no downtime, no user impact, no data loss.
The first step is knowing your database engine. In PostgreSQL, ALTER TABLE ADD COLUMN is straightforward, but adding defaults and non-null constraints can hold locks for longer than you expect. In MySQL, online DDL support depends on the storage engine and version. In cloud-managed databases, operations may be throttled or routed differently.
Always create the column without constraints or defaults first. Fill it in batches using a background job. Then apply constraints in a separate transaction. This reduces lock contention and keeps replication healthy. For large tables, verify row count changes using checksums before switching application logic.