Adding a new column should be simple. In reality, it can break production if not handled right. Schema changes are high‑risk when they touch large tables or critical transactions. A blocking migration can stall your app, lock writes, and cause downtime. Precision matters.
Before adding a new column, define if it is nullable, set defaults, and check the impact on indexes. For large datasets, avoid full table rewrites. Use online schema change tools like gh-ost or pt-online-schema-change to apply changes without locks. Migrate in phases:
- Add the new column without constraints.
- Backfill data in batches.
- Add constraints or indexes after the data is in place.
In application code, support both old and new schemas during the rollout. Deploy the migration before code depends on the new column. Use feature flags to control when the application reads or writes to it. This reduces the chance of race conditions or failed queries mid‑deployment.