The migration failed at step four because the new column was missing. No warning. No safety net. Just broken queries and locked tables.
Adding a new column should be simple, but in real systems simplicity hides in the details. Schema changes can block writes, slow reads, and trigger costly downtime if they aren’t planned and executed with precision. This is true whether you’re adding a nullable field, introducing a default value, or refactoring with a NOT NULL constraint.
Before adding a new column, check the database engine’s DDL behavior. Some systems can add columns instantly; others rewrite entire tables. Online schema change tools like pt-online-schema-change or gh-ost can help, but they require careful configuration and testing. Always benchmark the migration on production-sized data.
Choose the right column type from the start. Changing types later often requires manual reprocessing. Define indexes only after evaluating real query patterns. Adding an index at the same time as the column can improve performance—or it can lock the table if done blindly.