-- Migration: revenue leak auto-detection foundation (Phase 0)
-- Created: 2026-07-20
-- Additive-only: adds detection metadata columns to revenue_leaks.
-- Existing manual leaks default to detection_type='manual'.

ALTER TABLE revenue_leaks ADD COLUMN detection_type VARCHAR(10) NOT NULL DEFAULT 'manual';
ALTER TABLE revenue_leaks ADD COLUMN detector_id VARCHAR(64);
ALTER TABLE revenue_leaks ADD COLUMN source_connector VARCHAR(32);
ALTER TABLE revenue_leaks ADD COLUMN rule_params_json JSON;

CREATE INDEX IF NOT EXISTS ix_revenue_leaks_detector_id ON revenue_leaks (detector_id);
