Smoke curled from the log file as the deploy finished. The migration was clean—except for one thing. You needed a new column.
Adding a new column sounds simple. It is not. At scale, schema changes can break production, stall queries, or lock tables. Doing it right means planning for zero downtime, understanding your database engine’s alter mechanics, and validating data before and after the change.
A new column starts with definition. Choose the name, type, nullability, and default value. In PostgreSQL and MySQL, ALTER TABLE ADD COLUMN is the standard command. In large datasets, this can trigger a table rewrite. That means blocking writes unless you use non-blocking methods like ADD COLUMN with defaults deferred via separate updates.
Think about constraints. Adding NOT NULL to a new column without a default will fail if existing rows lack data. Use NULL first, backfill in batches, then set NOT NULL. For indexed columns, wait until after data is loaded to avoid locking overhead during creation.