All checks were successful
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
27 lines
997 B
SQL
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);
|