ALTER TABLE workshop_notification_outbox
  ADD COLUMN locked_at DATETIME NULL AFTER last_error,
  ADD COLUMN locked_by VARCHAR(120) NULL AFTER locked_at,
  ADD COLUMN delivered_at DATETIME NULL AFTER locked_by,
  ADD COLUMN message_id VARCHAR(190) NULL AFTER delivered_at,
  ADD KEY idx_workshop_notification_claim (
    processed_at, available_at, attempt_count, locked_at
  );

INSERT INTO migrations (migration, batch)
SELECT '006_workshop_notification_delivery', COALESCE(MAX(batch), 0) + 1
FROM migrations
WHERE NOT EXISTS (
  SELECT 1 FROM migrations WHERE migration = '006_workshop_notification_delivery'
);
