The code won’t ship until the data is right. You open the database schema and realize the table needs a new column. One more field to store critical data. Simple in theory. Dangerous in practice if you get it wrong.
Adding a new column in production requires precision. Schema changes can lock tables. Incorrect defaults can break queries. Migrations can stall under load. The key is to design and execute the change without risking uptime or corrupting data.
First, decide the type and constraints for the new column. Think about nullability, indexing, and storage. Avoid expensive defaults that rewrite every row. If possible, create the column with NULL allowed, then backfill data in small batches before enforcing a NOT NULL constraint.
Run the migration in a controlled environment before touching production. This includes staging databases with production-scale data. Measure execution time and check for query plan changes. Monitor for locks and replication lag.