The migration failed on the third step because the table was missing a new column.
Adding a new column sounds simple, but in production, it is a high‑risk change. Every schema change touches performance, data integrity, and deployment speed. The wrong approach can lock tables, block writes, or trigger cascading failures. The right approach is predictable, reversible, and easy to automate.
A new column in SQL is defined with ALTER TABLE. On small datasets, it’s instant. On large systems, the DDL can run for minutes or hours. This blocks queries depending on the database engine and configuration. Tools like gh-ost, pt-online-schema-change, or built‑in partition operations can make the process non‑blocking. Select a strategy that matches your database vendor, replication setup, and downtime tolerance.
Default values on a new column add another challenge. Setting a default for all existing rows at once can saturate I/O. Instead, add the column as nullable, backfill in batches, then attach constraints or defaults afterward. This minimizes lock contention and spreads load over time.