customer/migrations/0002_privacy.sql
Peppa ec434cab38
All checks were successful
peppa/lint lint: success за 1с
peppa/typecheck typecheck: success за 2с
peppa/test test: success за 16с
peppa/build build: success за 2с
ci / checks (pull_request) Successful in 29s
deploy / deploy (pull_request) Successful in 3s
CLT-3: шифрованное хранилище загрузок, журнал доступа, юридические страницы
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-15 13:34:06 +05:00

27 lines
997 B
SQL

CREATE TABLE uploads (
id uuid PRIMARY KEY,
org_id uuid REFERENCES organizations (id) ON DELETE CASCADE,
owner_user_id uuid REFERENCES users (id) ON DELETE SET NULL,
kind text NOT NULL,
ciphertext bytea NOT NULL,
nonce bytea NOT NULL,
key_id text NOT NULL,
size integer NOT NULL,
created_at timestamptz NOT NULL DEFAULT now(),
expires_at timestamptz NOT NULL
);
CREATE INDEX uploads_expires_at_idx ON uploads (expires_at);
-- Журнал доступа: только идентификаторы, без содержимого, IP и User-Agent.
CREATE TABLE access_log (
id bigserial PRIMARY KEY,
at timestamptz NOT NULL DEFAULT now(),
actor_user_id uuid REFERENCES users (id) ON DELETE SET NULL,
org_id uuid,
action text NOT NULL CHECK (action IN ('store', 'read', 'complete', 'expire')),
resource_type text NOT NULL,
resource_id text NOT NULL,
outcome text NOT NULL CHECK (outcome IN ('ok', 'denied'))
);
CREATE INDEX access_log_at_idx ON access_log (at);