customer/migrations/0004_kits.sql
Peppa 3b808eb937
All checks were successful
peppa/lint lint: success за 1с
peppa/typecheck typecheck: success за 2с
deploy / deploy (pull_request) Successful in 24s
peppa/test test: success за 18с
peppa/build build: success за 1с
ci / checks (pull_request) Successful in 31s
CLT-5: цифровые комплекты — генерация XLSX, проверка, подписанные ссылки выдачи
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-15 14:07:35 +05:00

28 lines
853 B
SQL

CREATE TABLE kits (
id uuid PRIMARY KEY,
offer_id text NOT NULL,
title text NOT NULL,
summary text NOT NULL DEFAULT '',
status text NOT NULL DEFAULT 'draft' CHECK (status IN ('draft', 'available')),
created_at timestamptz NOT NULL DEFAULT now()
);
CREATE TABLE kit_files (
id uuid PRIMARY KEY,
kit_id uuid NOT NULL REFERENCES kits (id) ON DELETE CASCADE,
name text NOT NULL,
content_type text NOT NULL,
size integer NOT NULL,
data bytea NOT NULL,
created_at timestamptz NOT NULL DEFAULT now(),
UNIQUE (kit_id, name)
);
-- Журнал скачиваний: без IP и содержимого.
CREATE TABLE kit_downloads (
id uuid PRIMARY KEY,
file_id uuid NOT NULL REFERENCES kit_files (id) ON DELETE CASCADE,
user_id uuid REFERENCES users (id) ON DELETE SET NULL,
created_at timestamptz NOT NULL DEFAULT now()
);