The migration failed halfway through. The error log pointed to a missing new column.
Adding a new column should be simple, yet it’s one of the most common points of failure in database changes. Whether you’re working with MySQL, PostgreSQL, SQL Server, or SQLite, the process comes down to precision, speed, and risk control. A poorly planned schema change can lock tables, drop indexes, or delay deployments.
The first rule: know your environment. In PostgreSQL, ALTER TABLE ADD COLUMN is usually fast if the column allows NULLs without a default. But adding a column with a default value can rewrite the whole table, blocking reads and writes. In MySQL, instant DDL support is improving, but older versions still require a full table rebuild for certain data types. In SQL Server, adding a nullable column is cheap; adding one with constraints can be expensive.
The second rule: control defaults and constraints. When possible, add the new column without a default or NOT NULL constraint, backfill data asynchronously in controlled batches, then apply the constraint. This keeps migrations fast and non-blocking.