-- Migration: 00011_stripe_identity_fields
-- Description: Add Stripe Identity session fields (keep existing verification_records for compatibility)
-- Date: 2025-12-21

-- Existing table `verification_records` was designed for Veriff.
-- We add Stripe Identity columns and make Veriff columns nullable for forward use.

ALTER TABLE verification_records
  ALTER COLUMN veriff_session_id DROP NOT NULL;

ALTER TABLE verification_records
  ADD COLUMN IF NOT EXISTS stripe_verification_session_id TEXT UNIQUE,
  ADD COLUMN IF NOT EXISTS stripe_verification_session_url TEXT,
  ADD COLUMN IF NOT EXISTS provider TEXT NOT NULL DEFAULT 'stripe_identity';

CREATE INDEX IF NOT EXISTS idx_verification_stripe_session
  ON verification_records(stripe_verification_session_id)
  WHERE stripe_verification_session_id IS NOT NULL;

COMMENT ON COLUMN verification_records.stripe_verification_session_id IS 'Stripe Identity verification_session.id (no PII)';
COMMENT ON COLUMN verification_records.stripe_verification_session_url IS 'Stripe-hosted verification URL (optional)';
COMMENT ON COLUMN verification_records.provider IS 'Verification provider identifier';


