ЛР4 - БВТ2303 - Голиков- на 4 #13

Closed
Maximillan_Mercer wants to merge 64 commits from Maximillan_Mercer/mtusi2026lab4-fork:solution/BVT2303-Golikov into main
Showing only changes of commit 4441156621 - Show all commits
+6 -2
View File
@@ -30,10 +30,10 @@ CREATE TABLE attachments (
CONSTRAINT attachments_object_key_len
CHECK (char_length(object_key) BETWEEN 1 AND 1024),
CONSTRAINT attachments_status_chk
CHECK (status IN ('ready', 'failed')),
CHECK (status IN ('ready', 'pending', 'failed')),
CONSTRAINT attachments_error_code_consistency
CHECK (
(status = 'ready' AND error_code IS NULL) OR
(status IN ('ready', 'pending') AND error_code IS NULL) OR
(status = 'failed' AND error_code IS NOT NULL)
)
);
@@ -44,6 +44,10 @@ CREATE UNIQUE INDEX attachments_object_key_uniq
CREATE INDEX attachments_chat_idx
ON attachments (chat_id, created_at, id);
CREATE INDEX attachments_pending_idx
ON attachments (created_at)
WHERE status = 'pending';
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 RESTRICT,