-- 021 : analyse automatique de la preuve de virement par IA
ALTER TABLE commissions
  ADD COLUMN IF NOT EXISTS proof_analysis_result JSONB NULL,
  ADD COLUMN IF NOT EXISTS proof_analysis_status VARCHAR(20) NULL,
  ADD COLUMN IF NOT EXISTS proof_analyzed_at TIMESTAMPTZ NULL;

COMMENT ON COLUMN commissions.proof_analysis_result IS 'Résultat JSON de l''analyse IA de la preuve (detected_amount, detected_iban, detected_date, matches...)';
COMMENT ON COLUMN commissions.proof_analysis_status IS 'valid | invalid | unclear | no_rib | error';
COMMENT ON COLUMN commissions.proof_analyzed_at IS 'Date de l''analyse IA';

SELECT column_name FROM information_schema.columns
WHERE table_name = 'commissions'
  AND column_name IN ('proof_analysis_result','proof_analysis_status','proof_analyzed_at');
