Реализовала требования лабы 4 на оценку 4

This commit is contained in:
vasyukova
2026-10-17 23:53:17 +03:00
parent 2d50adb37c
commit 442cd82653
9 changed files with 674 additions and 70 deletions
+28
View File
@@ -104,6 +104,34 @@ CREATE TABLE IF NOT EXISTS idempotency_keys (
);
CREATE INDEX IF NOT EXISTS idx_idempotency_created
ON idempotency_keys (created_at);
-- lab4: вложения
CREATE TABLE IF NOT EXISTS attachments (
id UUID PRIMARY KEY,
chat_id UUID NOT NULL REFERENCES chats(id) ON DELETE CASCADE,
owner_id UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE,
filename TEXT NOT NULL,
content_type TEXT NOT NULL,
size_bytes BIGINT NOT NULL,
sha256 TEXT NOT NULL,
object_key TEXT NOT NULL UNIQUE,
status TEXT NOT NULL, -- ready (lab4), queued/processing/failed (lab5)
error_code TEXT,
created_at TIMESTAMPTZ NOT NULL,
updated_at TIMESTAMPTZ NOT NULL
);
CREATE INDEX IF NOT EXISTS idx_attachments_chat
ON attachments (chat_id);
-- связь сообщение↔вложение (порядок сохраняем)
CREATE TABLE IF NOT EXISTS message_attachments (
message_id UUID NOT NULL REFERENCES messages(id) ON DELETE CASCADE,
attachment_id UUID NOT NULL REFERENCES attachments(id) ON DELETE CASCADE,
position INT NOT NULL,
PRIMARY KEY (message_id, attachment_id)
);
CREATE INDEX IF NOT EXISTS idx_msg_att_message
ON message_attachments (message_id, position);
"""