The database table is ready, but the schema is missing one thing: a new column. You add it, run the migration, and push it to production. Simple—until it isn’t.
Adding a new column is more than changing table structure. It affects queries, indexes, constraints, and downstream services. In high-traffic systems, a poorly executed ALTER TABLE can lock writes, slow reads, or cascade failures through dependent APIs.
First, decide the type and constraints of the new column. Choose the smallest type that holds all possible values. Avoid NULL unless the absence of data has meaning. If the new column must be populated for existing rows, plan how to backfill data without blocking operations.
For large datasets, use an online migration strategy. In Postgres, consider adding the column without default values first. Then backfill in batches to avoid table rewrites. In MySQL, check if your storage engine supports instant column addition. If not, build a shadow table, sync changes, and swap when ready.