The screen flashes red. A migration failed. The log points to one change: a new column.
Adding a new column to a production database sounds simple. It can be, but only if the change is done with control. Without planning, schema changes can lock tables, block writes, or cause downtime. Each database engine behaves differently, and the wrong ALTER TABLE can stall an application under load.
The first step: confirm why the new column is required. Define its data type, constraints, and default values. Avoid NOT NULL with defaults on massive tables unless you can tolerate a full table rewrite. Instead, create the column nullable, backfill in batches, then enforce constraints. For fields that need an index, create the index after backfill to avoid excessive locking.
In PostgreSQL, ALTER TABLE ADD COLUMN is fast for empty columns without defaults. In MySQL, the storage engine may copy the table, making it a heavy operation. For large datasets, online schema change tools like pg_repack, gh-ost, or pt-online-schema-change can keep services responsive while adding new columns.