-- AlterTable: tambah dukungan re-upload request, submission history,
-- dan manual override admin untuk OrganizerVerification.
--
-- Phase 2 (re-upload request): admin minta organizer upload ulang field
-- tertentu tanpa drop & recreate row.
ALTER TABLE "OrganizerVerification"
  ADD COLUMN "reuploadRequested" BOOLEAN NOT NULL DEFAULT false,
  ADD COLUMN "reuploadFields" TEXT[] DEFAULT ARRAY[]::TEXT[],
  ADD COLUMN "reuploadNote" TEXT;

-- Phase 3 (submission history): track jumlah submission + arsip rejection
-- reason setiap kali REJECTED (sebelum di-overwrite saat submit ulang).
-- `previousRejections` = array string `[{"at": "...", "reason": "..."}]`
-- yang di-append manual oleh service saat reject baru terjadi.
ALTER TABLE "OrganizerVerification"
  ADD COLUMN "submissionCount" INTEGER NOT NULL DEFAULT 1,
  ADD COLUMN "previousRejections" JSONB;

-- Phase 4 (manual override): flag bahwa verifikasi dibuat admin tanpa
-- upload KYC (mis. referral dari partner trusted). Untuk audit transparansi.
ALTER TABLE "OrganizerVerification"
  ADD COLUMN "isManualOverride" BOOLEAN NOT NULL DEFAULT false,
  ADD COLUMN "manualOverrideById" TEXT,
  ADD COLUMN "manualOverrideNote" TEXT;

-- FK admin yang manual-override — SET NULL kalau admin dihapus.
ALTER TABLE "OrganizerVerification" ADD CONSTRAINT
  "OrganizerVerification_manualOverrideById_fkey"
  FOREIGN KEY ("manualOverrideById") REFERENCES "User"("id")
  ON DELETE SET NULL ON UPDATE CASCADE;
