papertrail/db/migrations/0034_templates.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

22 lines
982 B
SQL

-- Reusable templates for claims, reports, verifications, and documents.
-- A template is a named, categorized JSONB body an org can duplicate and apply
-- when creating the corresponding entity — e.g. a standard report layout or a
-- claim-intake field set. Org-scoped (multi-tenant) with uuid pks and created_at.
-- Idempotent — safe to run repeatedly.
create table if not exists templates (
id uuid primary key default gen_random_uuid(),
org_id uuid not null references orgs(id) on delete cascade,
kind text not null,
name text not null,
description text,
body jsonb not null default '{}'::jsonb,
category text,
created_by uuid references users(id) on delete set null,
created_at timestamptz not null default now()
);
create index if not exists templates_org_id_idx on templates (org_id);
create index if not exists templates_org_kind_idx on templates (org_id, kind);
create index if not exists templates_org_category_idx on templates (org_id, category);