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>
35 lines
1.7 KiB
SQL
35 lines
1.7 KiB
SQL
-- Data export center. A data_export is one org-scoped, materialized export of a
|
|
-- single data domain (`scope` — claims / verifications / evidence / documents /
|
|
-- references) serialized to a `format` (csv / json). `params` jsonb records the
|
|
-- request (e.g. project narrowing) so the export is reproducible, `row_count`
|
|
-- caches how many rows the build produced, and `status` tracks the lifecycle so
|
|
-- the history view can render pending / complete / failed states without
|
|
-- recomputing. The generated document itself is rebuilt on demand by the
|
|
-- download route from the same scope/format/params, so no blob is stored here.
|
|
--
|
|
-- Every row carries org_id and cascades from orgs so one tenant can never read
|
|
-- or mutate another tenant's exports. Idempotent: safe to run repeatedly.
|
|
|
|
create table if not exists data_exports (
|
|
id uuid primary key default gen_random_uuid(),
|
|
org_id uuid not null references orgs(id) on delete cascade,
|
|
scope text not null
|
|
check (scope in ('claims', 'verifications', 'evidence', 'documents', 'references')),
|
|
format text not null default 'csv'
|
|
check (format in ('csv', 'json')),
|
|
status text not null default 'pending'
|
|
check (status in ('pending', 'processing', 'complete', 'failed')),
|
|
row_count integer not null default 0,
|
|
params jsonb not null default '{}'::jsonb,
|
|
created_by uuid references users(id) on delete set null,
|
|
created_at timestamptz not null default now()
|
|
);
|
|
|
|
-- The common access path: list an org's exports newest-first.
|
|
create index if not exists data_exports_org_id_idx
|
|
on data_exports(org_id, created_at desc);
|
|
|
|
-- Filter an org's history by scope (e.g. only claim exports).
|
|
create index if not exists data_exports_org_scope_idx
|
|
on data_exports(org_id, scope, created_at desc);
|