Blocking Pattern (Avoid in Production)

ALTER TABLE shipments MODIFY COLUMN tracking_code VARCHAR(128) NOT NULL;

Zero-Downtime Safe Rewrite

ALTER TABLE shipments ADD INDEX idx_shipments_carrier (carrier_code, dispatched_at),
  ALGORITHM=INPLACE, LOCK=NONE;

Production Rollout Notes

  • Explicit LOCK=NONE makes MySQL fail fast instead of silently causing a production outage.
  • For operations that require COPY (such as data type rewrites), use gh-ost or pt-online-schema-change.