The migration stalled. The schema was locked, queries piled up, and the fix was one line: add a new column.
Creating a new column in a production database is simple in theory, dangerous in practice. Done right, it unlocks features and refactors. Done wrong, it freezes your system. Precision matters.
Start with the basics. Know your database engine. In PostgreSQL, ALTER TABLE ADD COLUMN is straightforward, but defaults and constraints can cause full table rewrites. In MySQL, a similar ALTER TABLE works, but storage engines and indexes change the performance profile. Avoid automatic defaults for large tables unless you can tolerate downtime or have queued writes.
Plan the migration. Add the new column without instantly populating every row. Set it nullable at first. Migrate data in batches using an update script. Build indexes only after the data transfer, or use concurrent index creation if supported.