papertrail/db/migrations/0002_org-team.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

21 lines
955 B
SQL

-- Organization & Team management. Uses foundation tables (orgs, users,
-- memberships, invitations, audit_log). Adds an org_settings table for
-- per-org configuration that doesn't belong on the orgs row itself.
-- Idempotent — safe to run repeatedly.
create table if not exists org_settings (
id uuid primary key default gen_random_uuid(),
org_id uuid not null unique references orgs(id) on delete cascade,
default_member_role text not null default 'viewer'
check (default_member_role in ('owner', 'admin', 'editor', 'viewer')),
require_review boolean not null default false,
created_at timestamptz not null default now(),
updated_at timestamptz not null default now()
);
create index if not exists org_settings_org_id_idx on org_settings(org_id);
-- Track who invited whom so pending-invitation lists can show the inviter.
alter table invitations
add column if not exists invited_by uuid references users(id) on delete set null;