The migration failed. The logs screamed about a missing column, and the clock was already past midnight.
Adding a new column should be the simplest database task. Yet in production systems with millions of rows, zero downtime requirements, and distributed read replicas, even a single schema change can be dangerous. A badly executed ALTER TABLE locks writes, slows queries, or brings an entire service to its knees.
The safest path to adding a new column starts with understanding the database engine’s capabilities. PostgreSQL handles ADD COLUMN as an instant metadata change if no default value is provided. MySQL can behave differently depending on storage engine and version. The command itself is rarely the problem—it’s the cascading changes that follow.
Plan the new column’s lifecycle. First, deploy a migration that creates the column with a NULL default. This step runs fast and avoids costly table rewrites. Then backfill data in small, throttled batches to prevent performance spikes. Only after the backfill completes should you add constraints, defaults, or indexes.