The migration finished at 3:17 a.m., but the data was already wrong. A missing NEW COLUMN in the schema had broken the entire release.
Adding a new column to a database table is one of the most common operations in application development, yet it’s also one of the most dangerous if mishandled. Schema changes affect queries, indexes, migrations, and performance under load. The wrong approach risks downtime, deadlocks, or inconsistent data.
Before adding a new column, confirm the purpose, type, default values, and nullability. For large tables, use a migration strategy that avoids locking writes. In MySQL and PostgreSQL, consider ADD COLUMN with no default, followed by a backfill and an ALTER TABLE to set the default after the fact. This avoids long table locks that can freeze production.
Always test queries using the new column in staging with realistic volumes. Adding indexes on the new column should happen after the backfill to avoid slowing down large write operations. Monitor query plans and ensure the optimizer picks up the expected index path.