Adding a new column to a database should be fast, predictable, and safe. Done wrong, it can lock tables, break queries, or bring production down. Done right, it becomes a seamless step in your deployment pipeline. The details matter — data type, constraints, defaults, and how this change will propagate across environments.
First, know your database engine. In PostgreSQL, ALTER TABLE ADD COLUMN is straightforward if the new column allows nulls or has no default. Adding a default with a non-null constraint can rewrite the table and take time. In MySQL, similar rules apply, but execution plans and storage engines can shift performance in different ways.
Second, plan for zero downtime. If you need a non-null column with a default, consider adding it nullable, backfilling in small batches, then applying the constraint. Use feature flags so code that depends on the new column isn’t deployed before data is ready.