Adding a new column to a live database is one of the most common schema changes, yet it’s also one of the most overlooked in terms of performance and safety. Done wrong, it locks tables, blocks writes, or triggers unexpected application errors. Done right, it rolls out without a blip in uptime.
The first step is to define exactly what the new column must store. Pick the data type carefully—changing it later is painful and can be expensive under load. Set NULL or NOT NULL based on your migration strategy. If you set NOT NULL with a default, many engines will rewrite the whole table.
On PostgreSQL, adding a column with a default will lock the table until the default is filled. A safer method is to add the new column as nullable, backfill data in small batches, then apply the constraint after. On MySQL, behavior differs between versions, so check whether your engine supports instant DDL for new columns.
In modern deployments, schema migrations should be automated, versioned, and reversible. Use a migration tool that can apply the new column change in a transaction if supported. Split the operation into phases: