The migration was live, and there was no turning back. A new column had to be added to the production database without downtime, without errors, and without losing a single row.
Adding a new column sounds simple until you factor in scale, traffic, and live queries. In SQL, an ALTER TABLE can lock rows or block writes, and on large datasets, the cost is high. The safest way to add a new column depends on your database engine—PostgreSQL, MySQL, or modern cloud systems—and how you deploy schema changes.
In PostgreSQL, adding a nullable column without a default is fast, as it only updates metadata. Adding a column with a default value rewrites the entire table, increasing I/O load. The optimal strategy is to create the new column as nullable, backfill it in batches, then add the default. MySQL behaves differently—older versions can require full table copies, while newer ones with ALGORITHM=INPLACE or INSTANT can handle it much faster.