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.4 KiB
SQL
35 lines
1.4 KiB
SQL
-- Document / PDF library & ingestion. Multi-tenant, org-scoped.
|
|
-- Stores uploaded document metadata plus extracted plain text (storage_key is a
|
|
-- placeholder for real blob storage). Idempotent — safe to run repeatedly.
|
|
|
|
create table if not exists documents (
|
|
id uuid primary key default gen_random_uuid(),
|
|
org_id uuid not null references orgs(id) on delete cascade,
|
|
project_id uuid,
|
|
filename text not null,
|
|
mime_type text not null default 'text/plain',
|
|
size_bytes integer not null default 0,
|
|
storage_key text,
|
|
extracted_text text,
|
|
status text not null default 'pending'
|
|
check (status in ('pending', 'processing', 'extracted', 'failed')),
|
|
uploaded_by uuid references users(id) on delete set null,
|
|
created_at timestamptz not null default now(),
|
|
updated_at timestamptz not null default now()
|
|
);
|
|
|
|
create index if not exists documents_org_id_idx on documents(org_id, created_at desc);
|
|
create index if not exists documents_project_id_idx on documents(project_id);
|
|
|
|
create table if not exists document_pages (
|
|
id uuid primary key default gen_random_uuid(),
|
|
document_id uuid not null references documents(id) on delete cascade,
|
|
page_number integer not null,
|
|
text text,
|
|
created_at timestamptz not null default now(),
|
|
unique (document_id, page_number)
|
|
);
|
|
|
|
create index if not exists document_pages_document_id_idx
|
|
on document_pages(document_id, page_number);
|