Files
sharangandClaude Opus 5.5 8d3cda4bb0
ci / shared (push) Successful in 12s
ci / test (push) Successful in 23m15s
ci / image (push) Successful in 31s
feat(documents): tenant documents with staff upload and signed downloads (#34)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB
2026-09-23 20:31:55 +00:00

24 lines
1.2 KiB
SQL

-- 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);