From 444115662169119a5b14341ac82a31c49ffcf3fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=93=D0=BE=D0=BB=D0=B8=D0=BA=D0=BE=D0=B2=20Maximillian?= =?UTF-8?q?=20=D0=90=D0=BD=D1=82=D0=BE=D0=BD?= Date: Mon, 19 Oct 2026 09:11:02 +0300 Subject: [PATCH] fix(migration):lab4 add pending status --- backend/migrations/0003_attachments.sql | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/backend/migrations/0003_attachments.sql b/backend/migrations/0003_attachments.sql index f532b87..4026857 100644 --- a/backend/migrations/0003_attachments.sql +++ b/backend/migrations/0003_attachments.sql @@ -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,