Adding a new column sounds simple, but in practice it can be one of the most dangerous schema changes. You have to think about downtime, default values, indexing, backfilling, and query performance. Done wrong, it locks tables, halts writes, and takes down critical services. Done right, it’s invisible to the user.
When adding a new column, the first decision is whether it can be nullable. Nullable columns deploy faster because they skip rewriting existing rows. If it must be NOT NULL, add it as nullable first, then backfill in batches, and finally alter the constraint. This avoids locking large tables and blocking queries.
For default values, be careful. Setting a default on the ALTER TABLE statement often rewrites the entire table. Instead, set it to NULL, backfill values, then set the default for future inserts.
Index strategy matters. Don’t create an index in the same migration as adding the column. Large indexes can double your deployment risk. Split them into separate, verified steps to shorten lock times and reduce rollback complexity.