The migration paused. Everyone stared at the schema. The change was small, but critical: a new column.
Adding a new column in a relational database is one of the most common operations, yet it carries risks that can cripple production if handled poorly. Schema changes touch storage, indexes, and queries in ways that ripple through the stack. The database might lock rows, block writes, or delay reads. In distributed systems, replication lag can spike. Migrations can cascade into downstream failures.
The first step is to define the column with absolute clarity. Name it in a way that matches existing conventions. Choose the smallest viable data type. Avoid NULL defaults unless they are required. For large tables, adding a column with a default value can trigger a full table rewrite, which means downtime or degraded performance. Instead, consider adding the column as nullable, backfilling data in batches, then applying constraints later.
Run the migration in a controlled environment before touching production. Test with real datasets, not just synthetic fixtures. Measure query performance before and after the new column exists. If you use ORM-generated migrations, read the generated SQL before executing. Automation is useful, but it should never be trusted blindly with schema changes.