The query ran. The rows came back clean. No one expected the schema to change—until it had to. You need a new column.
Adding a new column sounds simple. But in systems under load, nothing is simple. Schema changes can block writes, cause replication lag, or lock tables. If you get it wrong, you stall the entire service. That’s why planning the migration is as important as the column itself.
First, choose the right migration strategy. For small datasets, a direct ALTER TABLE ... ADD COLUMN may work without downtime. For large datasets, use an online schema change tool such as pt-online-schema-change for MySQL or pg_repack for PostgreSQL. These tools copy data into a new table, add the column without locking, and then swap tables in a short cutover.
Second, define defaults carefully. Adding a non-nullable column with a default can rewrite every row, increasing migration time. Instead, add it as nullable, backfill data in batches, and then apply a constraint later.