-- Migration 021: Add defer_until to formation_orders for holiday/schedule deferred jobs
BEGIN;
ALTER TABLE formation_orders ADD COLUMN IF NOT EXISTS defer_until TIMESTAMPTZ;
CREATE INDEX IF NOT EXISTS idx_formation_orders_deferred
  ON formation_orders (defer_until)
  WHERE automation_status = 'Deferred' AND defer_until IS NOT NULL;
COMMIT;
