-- 033_vvt_consolidation.sql
-- Portiert Go-exklusive VVT-Features nach Python (Source of Truth)
-- P0: Review-Daten, created_by | P1: DSFA-Link

ALTER TABLE compliance_vvt_activities
  ADD COLUMN IF NOT EXISTS last_reviewed_at TIMESTAMPTZ,
  ADD COLUMN IF NOT EXISTS next_review_at TIMESTAMPTZ,
  ADD COLUMN IF NOT EXISTS created_by VARCHAR(200) DEFAULT 'system',
  ADD COLUMN IF NOT EXISTS dsfa_id UUID;

CREATE INDEX IF NOT EXISTS idx_vvt_activities_dsfa
  ON compliance_vvt_activities(dsfa_id) WHERE dsfa_id IS NOT NULL;
CREATE INDEX IF NOT EXISTS idx_vvt_activities_next_review
  ON compliance_vvt_activities(next_review_at) WHERE next_review_at IS NOT NULL;
