fix(migration):lab4 add pending status

This commit is contained in:
Голиков Maximillian Антон
2026-10-19 09:11:02 +03:00
parent 84994921bb
commit 4441156621
+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,