-- Add 'auto_capture' to lead_type ENUM in app_calls table.

ALTER TABLE app_calls
    MODIFY COLUMN lead_type ENUM('trash','missed','normal_lead','qualified_lead','measurement','order','auto_capture') NOT NULL;

-- Fix existing rows that got stored as empty string due to invalid ENUM value.
UPDATE app_calls
    SET lead_type = 'auto_capture'
    WHERE lead_type = ''
      AND JSON_UNQUOTE(JSON_EXTRACT(raw_payload_json, '$.lead_type')) = 'auto_capture';
