Отделить приём вложений от обработки через очередь и worker.

This commit is contained in:
samsik
2026-11-20 01:30:00 +03:00
parent 276dbdad8a
commit b92fa218ba
40 changed files with 4054 additions and 33 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)
);