Adding a new column sounds simple. It isn’t always. Done wrong, it locks tables, slows queries, or breaks production code. At scale, a single migration can stall an entire system. The right approach avoids downtime, preserves data integrity, and keeps deployments safe.
First, decide if the new column is nullable or requires a default value. Non-null columns with defaults can cause full table rewrites on large datasets. Use NULL where possible, then backfill in small batches. This keeps operations fast and predictable.
Second, choose the right migration strategy. In PostgreSQL, ALTER TABLE ADD COLUMN is fast for nullable columns. For large writes, break work into background jobs. In MySQL, adding a column to an InnoDB table can still require a table copy without ALGORITHM=INPLACE. Always check the engine behavior before running in production.