Перенос кода из ЛР5 в ЛР6 (начало)

This commit is contained in:
2026-11-24 15:44:25 +03:00
parent 470d9d6f1e
commit a1071c87e9
71 changed files with 3179 additions and 0 deletions
@@ -0,0 +1,20 @@
CREATE TABLE 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 VARCHAR(255) NOT NULL,
content_type VARCHAR(100) NOT NULL,
size_bytes BIGINT NOT NULL,
sha256 VARCHAR(64) NOT NULL,
object_key VARCHAR(255) NOT NULL,
created_at TIMESTAMP WITH TIME ZONE NOT NULL
);
CREATE INDEX idx_attachments_chat_id ON attachments (chat_id);
-- Связь сообщений с вложениями (Many-to-Many)
CREATE TABLE message_attachments (
message_id UUID NOT NULL REFERENCES messages(id) ON DELETE CASCADE,
attachment_id UUID NOT NULL REFERENCES attachments(id) ON DELETE CASCADE,
PRIMARY KEY (message_id, attachment_id)
);