Собрать стенд lab4 с вложениями в приватном S3-bucket.

Метаданные остаются в PostgreSQL, байты — в RustFS, чтобы скачивание пережило остановку одной реплики API.
This commit is contained in:
samsik
2026-11-06 08:49:44 +03:00
parent ec540a1a72
commit 11c8c03984
32 changed files with 2348 additions and 50 deletions
+27
View File
@@ -0,0 +1,27 @@
-- Метаданные вложения. Байты лежат в приватном S3-bucket, не в этой таблице.
-- object_key назначает сервер. filename только для отображения.
-- Связь сообщения и вложения — message_attachments, порядок задаёт position.
CREATE TABLE attachments (
id uuid PRIMARY KEY,
chat_id uuid NOT NULL REFERENCES chats (id),
owner_id uuid NOT NULL REFERENCES users (id),
filename text NOT NULL,
content_type text NOT NULL,
size_bytes integer NOT NULL,
sha256 text NOT NULL,
object_key text NOT NULL,
width integer NOT NULL,
height integer NOT NULL,
created_at timestamptz NOT NULL,
CONSTRAINT attachments_object_key_unique UNIQUE (object_key)
);
CREATE INDEX attachments_chat_idx ON attachments (chat_id, created_at, id);
CREATE TABLE message_attachments (
message_id uuid NOT NULL REFERENCES messages (id),
attachment_id uuid NOT NULL REFERENCES attachments (id),
position integer NOT NULL,
PRIMARY KEY (message_id, attachment_id)
);