The build was done, the tests were green, but the database migration failed. A missing new column stopped the release cold.
Adding a new column sounds trivial, but the wrong approach can lock tables, break queries, and slow production traffic. To get it right, you need a method that works under load, handles data backfill without blocking, and keeps schema changes predictable.
Use ALTER TABLE for small datasets when downtime is acceptable. For large, live systems, pair ONLINE DDL with transactional migrations to avoid table locks. In Postgres, use ADD COLUMN with a default set to NULL first, then backfill in batches before setting a NOT NULL constraint. In MySQL, prefer ALGORITHM=INPLACE where supported.
Naming the new column matters. Align it with the domain model. Avoid generic names like data or flag. Define type, default, and constraints explicitly. Document it at the time of creation—future changes are costly.