-- Migration 028: DSFA AI Use Cases
-- Adds ai_use_case_modules (JSONB) and section_8_complete (BOOLEAN) to compliance_dsfas

ALTER TABLE compliance.compliance_dsfas
  ADD COLUMN IF NOT EXISTS ai_use_case_modules JSONB DEFAULT '[]'::jsonb,
  ADD COLUMN IF NOT EXISTS section_8_complete BOOLEAN DEFAULT FALSE;

-- Extend section_progress JSONB for existing rows
UPDATE compliance.compliance_dsfas
SET section_progress = section_progress || '{"section_8_complete": false}'::jsonb
WHERE section_progress IS NOT NULL
  AND NOT (section_progress ? 'section_8_complete');
