-- Admin-recorded adjudication outcome per initiative (linked to applicant application id API).
-- One row per initiative; CRUD via /api/applications/{applicationId}/admin-result

CREATE TABLE IF NOT EXISTS application_admin_results (
  id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
  initiative_id UUID NOT NULL REFERENCES initiatives(id) ON DELETE CASCADE,
  decision TEXT NOT NULL CHECK (decision IN ('approved','rejected')),
  feedback TEXT NOT NULL DEFAULT '',
  rationale TEXT,
  created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
  updated_at TIMESTAMPTZ NOT NULL DEFAULT now(),
  created_by UUID REFERENCES users(id),
  updated_by UUID REFERENCES users(id),
  CONSTRAINT uq_application_admin_results_initiative UNIQUE (initiative_id)
);

CREATE INDEX IF NOT EXISTS idx_application_admin_results_initiative
  ON application_admin_results(initiative_id);
