The migration halted. The team stared at the schema diff. A single phrase glared back from the plan: New Column.
Adding a new column to a live database is simple in code yet dangerous in practice. A careless ALTER TABLE on a large dataset can lock writes, cause downtime, or trigger costly replication lag. The safe approach depends on your database engine, your scale, and your deployment process.
In PostgreSQL, adding a nullable column without a default is fast. The operation updates metadata only. But adding a NOT NULL column with a default rewrites the table, blocking access. In MySQL, operations vary depending on storage engine and version. Use ALGORITHM=INSTANT where supported to avoid a full table copy.
Every new column requires a plan. Start with a migration file that is explicit and reversible. Populate the column in small batches using background jobs. Add indexes in separate migrations. Monitor query patterns before and after. Roll out application changes in stages so both old and new code paths can run safely.