-- Enhanced Discovery Sessions - Additional Fields
-- 020_discovery_sessions_enhanced.sql

-- Add success_criteria to Step 1 (Objectives)
ALTER TABLE discovery_sessions ADD COLUMN IF NOT EXISTS success_criteria TEXT;

-- Ensure current_step can be 6 (for Best Practices step)
-- (INT already supports 6, but let's document it)
COMMENT ON COLUMN discovery_sessions.current_step IS 'Current step in wizard: 1=Objectives, 2=Scope, 3=Approach, 4=Preparation, 5=Execute, 6=Best Practices';

-- Add quality_checks field (for Step 4 - user input before quality_check_results)
ALTER TABLE discovery_sessions ADD COLUMN IF NOT EXISTS quality_checks JSONB;

-- Add job_name, schedule, and notifications for Step 5 (Execute)
ALTER TABLE discovery_sessions ADD COLUMN IF NOT EXISTS job_name VARCHAR(255);
ALTER TABLE discovery_sessions ADD COLUMN IF NOT EXISTS schedule_config JSONB; -- {type: 'now'|'scheduled'|'recurring', date?: string, cron?: string}
ALTER TABLE discovery_sessions ADD COLUMN IF NOT EXISTS notification_config JSONB; -- {on_completion, on_errors, on_spikes, recipients, channels}

COMMENT ON COLUMN discovery_sessions.quality_checks IS 'User-provided quality checks: {ocr_samples: [], classification_samples: []}';
COMMENT ON COLUMN discovery_sessions.quality_check_results IS 'Results from quality checks: {ocr_accuracy, classification_confidence}';
COMMENT ON COLUMN discovery_sessions.success_criteria IS 'Success criteria for the discovery session (Step 1)';
COMMENT ON COLUMN discovery_sessions.job_name IS 'Custom name for the discovery job (Step 5)';
COMMENT ON COLUMN discovery_sessions.schedule_config IS 'Schedule configuration: {type: "now"|"scheduled"|"recurring", date?: string, cron?: string}';
COMMENT ON COLUMN discovery_sessions.notification_config IS 'Notification settings: {on_completion, on_errors, on_spikes, recipients: [], channels: [], watermark_enabled, watermark_template}';

