-- F2 (go-live 2026-09): documents BreakPilot hands to a tenant (conformity -- documents, reports) until breakpilot-compliance delivers them itself. Staff -- upload a draft, publish it, and only then does the tenant see it. The file -- lives in object storage under object_key; this row is its index. CREATE TABLE documents ( id UUID PRIMARY KEY DEFAULT gen_random_uuid(), tenant_id UUID NOT NULL REFERENCES tenants(id) ON DELETE CASCADE, title TEXT NOT NULL CHECK (char_length(title) BETWEEN 1 AND 200), description TEXT NOT NULL DEFAULT '' CHECK (char_length(description) <= 2000), filename TEXT NOT NULL, content_type TEXT NOT NULL, size_bytes BIGINT NOT NULL CHECK (size_bytes >= 0), sha256 TEXT NOT NULL, object_key TEXT NOT NULL UNIQUE, status TEXT NOT NULL DEFAULT 'draft' CHECK (status IN ('draft', 'published')), uploaded_by TEXT NOT NULL DEFAULT '', published_by TEXT, published_at TIMESTAMPTZ, created_at TIMESTAMPTZ NOT NULL DEFAULT now(), updated_at TIMESTAMPTZ NOT NULL DEFAULT now() ); CREATE INDEX documents_tenant_created ON documents (tenant_id, created_at DESC);