To add a new column safely, you must control both the migration process and how application code evolves alongside it. A direct ALTER TABLE is fast for small datasets, but it can lock tables, spike load, and stall queries. For large or high-traffic systems, use online schema changes. Tools like pt-online-schema-change or native database features for concurrent migrations avoid downtime by migrating in the background.
Define the new column with the correct type and constraints from the start. Changing them later can force full table rewrites. If your column needs a default value, set it explicitly—don’t rely on implicit nulls unless you know your query patterns can handle them. Add indexes only when required, and measure their impact on write performance.
Coordinate deployments across services. Ship the schema change first, then release application code that writes to the new column. Read logic should handle both the presence and absence of data until backfill is complete. Backfill in batches, throttling writes to avoid saturating I/O. Track progress with metrics, and cancel if error rates rise.