The dataset was large. But one thing was missing: a new column.
Adding a new column sounds simple, but in modern systems it can be a high‑risk change. Schema migrations touch production data. They can block writes, lock tables, or slow queries if done wrong. The right approach depends on your database, traffic patterns, and deployment constraints.
In SQL databases like PostgreSQL or MySQL, ALTER TABLE ADD COLUMN is the basic command. On small tables, it’s nearly instant. On large ones, it can trigger a table rewrite. This can stall your pipeline. Always check the size of the target table, replication lag, and lock behavior before executing.
For high‑volume systems, online schema change tools (like gh-ost for MySQL or pg_online_schema_change for PostgreSQL) add new columns without blocking writes. They create a shadow table, sync it, then swap it in. This takes more steps but keeps downtime near zero.
Default values require care. In PostgreSQL, setting a default and NOT NULL in the same migration can force a full table rewrite. Split the operation: