ALTER TABLE commissions
  ADD COLUMN IF NOT EXISTS franchisee_confirmed_at TIMESTAMPTZ NULL,
  ADD COLUMN IF NOT EXISTS proof_url TEXT NULL,
  ADD COLUMN IF NOT EXISTS proof_date DATE NULL,
  ADD COLUMN IF NOT EXISTS contest_deadline TIMESTAMPTZ NULL,
  ADD COLUMN IF NOT EXISTS contested_at TIMESTAMPTZ NULL,
  ADD COLUMN IF NOT EXISTS contest_reason TEXT NULL;

COMMENT ON COLUMN commissions.franchisee_confirmed_at IS 'Date à laquelle le franchisé a marqué cette commission comme versée';
COMMENT ON COLUMN commissions.proof_url IS 'URL de la preuve de virement (par commission)';
COMMENT ON COLUMN commissions.proof_date IS 'Date d''opération bancaire déclarée par le franchisé';
COMMENT ON COLUMN commissions.contest_deadline IS 'Date limite pour que l''ambassadeur conteste (franchisee_confirmed_at + 10j)';
COMMENT ON COLUMN commissions.contested_at IS 'Date de contestation par l''ambassadeur';
COMMENT ON COLUMN commissions.contest_reason IS 'Motif de contestation saisi par l''ambassadeur';

SELECT column_name FROM information_schema.columns
WHERE table_name = 'commissions'
  AND column_name IN ('franchisee_confirmed_at','proof_url','proof_date','contest_deadline','contested_at','contest_reason');
