The migration failed on the last step. The schema was correct, but the query died because the new column didn’t exist in production. Everyone stared at the error log. One missing field had put the release on hold.
Adding a new column should be trivial. In SQL, it’s a simple ALTER TABLE command. But in real systems, you must think about downtime, replication lag, lock contention, and the impact on application code. Schema changes touch live data, and a wrong move can block writes or break features.
The first step is planning. Decide the column name, type, and constraints. Ask if it can be nullable to avoid rewriting all rows at once. For high-traffic tables, non-null columns with defaults can cause full table rewrites. This will lock the table and stall queries.
Deploy schema changes in small, safe steps. Add the new column without constraints. Deploy application code that can write and read from it. Backfill data in batches to prevent load spikes. Only then add constraints or indexes. Each step reduces risk and makes rollbacks possible.