papertrail/db/migrations/0007_reviews.sql
caelum0x 695a365ae4 feat: PaperTrail — enterprise evidence-verification platform
Multi-tenant platform (182 pages, 228 API routes, ~30 modules) built on a
deterministic verification core: clinical-trial claims checked against
ClinicalTrials.gov registered results and raw event counts (ARR/NNT/RR+CI
recomputed in code, oracle-tested), code-enforced exact-span grounding, and
multi-source cross-verification. Auth/RBAC/multi-tenancy, document processing
at scale (unpdf + Docling), agentic workflows, Claude Science connector,
compliance/audit, billing, public API, and more.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-08 07:21:22 +03:00

29 lines
1.3 KiB
SQL

-- Review workflows: assign verifications/claims for human review & approval.
-- Multi-tenant (org_id on every row). Idempotent — safe to run repeatedly.
--
-- project_id and claim_id are plain uuids (no FK) because those tables are
-- owned by sibling modules; keeping them unconstrained avoids cross-module
-- migration ordering coupling. All queries still filter by org_id.
create table if not exists reviews (
id uuid primary key default gen_random_uuid(),
org_id uuid not null references orgs(id) on delete cascade,
project_id uuid,
claim_id uuid,
assignee_id uuid references users(id) on delete set null,
reviewer_id uuid references users(id) on delete set null,
status text not null default 'pending'
check (status in ('pending', 'in_review', 'approved', 'rejected', 'cancelled')),
decision text
check (decision is null or decision in ('approved', 'rejected')),
comment text,
due_date timestamptz,
created_at timestamptz not null default now(),
updated_at timestamptz not null default now()
);
create index if not exists reviews_org_id_idx on reviews(org_id, created_at desc);
create index if not exists reviews_assignee_idx on reviews(org_id, assignee_id);
create index if not exists reviews_status_idx on reviews(org_id, status);
create index if not exists reviews_claim_idx on reviews(org_id, claim_id);