Adding a new column to a database sounds simple. It isn’t. Done wrong, it can lock tables, stall writes, crash services, and turn deployments into outages. Done right, it is invisible to users and safe for production.
The first step is to choose the right migration approach. For small datasets, a direct ALTER TABLE ADD COLUMN may be fine. For high-traffic systems, you need an online migration strategy. Tools like pt-online-schema-change or gh-ost can avoid downtime by creating a shadow table and migrating data in the background.
Default values matter. Setting a default on a new column can trigger a full table rewrite, costing minutes or hours depending on size. Instead, add the column as nullable, backfill it in controlled batches, and then alter it to set a default once the data is in place.
Indexing a new column must be delayed until after backfill. Adding an index at creation time compounds the impact of the migration. Build indexes in separate operations to keep locks short.