Выполнение лабораторной работы номер 7
Skeleton contracts / contracts (pull_request) Canceled after 0s

This commit is contained in:
2026-12-04 18:15:18 +03:00
parent 20afc2c790
commit 2fae615742
77 changed files with 5212 additions and 64 deletions
+17
View File
@@ -0,0 +1,17 @@
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 BIGINT NOT NULL,
sha256 TEXT NOT NULL,
object_key TEXT NOT NULL UNIQUE,
status TEXT NOT NULL CHECK (status IN ('pending', 'ready')),
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT now()
);
ALTER TABLE messages DROP CONSTRAINT messages_text_check;
ALTER TABLE messages ADD CONSTRAINT messages_text_check CHECK (char_length(text) <= 4000);
ALTER TABLE messages ADD COLUMN attachment_ids UUID[] NOT NULL DEFAULT '{}';
CREATE INDEX attachments_pending_idx ON attachments(created_at) WHERE status = 'pending';