Data shifted. Queries broke. Pipelines stalled.
Adding a new column should be simple, but database changes in production are rarely simple. Schema migrations carry risk: broken deployments, data loss, or degraded performance. The wrong approach can create a cascade of downstream failures. The right approach keeps your system stable while evolving.
A new column means more than an ALTER TABLE command. You must account for locks, replication lag, and storage growth. Different databases behave differently—PostgreSQL may rewrite the entire table depending on the change, while MySQL might only adjust metadata. Understanding the execution path of your migration is critical.
For zero-downtime migrations, create the column with default NULL, then backfill in controlled batches. Avoid setting a non-null default during creation, as it can trigger table rewrites. Once the data is populated and queries updated to handle the new field, enforce constraints in a separate migration.