fix(migration):lab4 add pending status
This commit is contained in:
@@ -30,10 +30,10 @@ CREATE TABLE attachments (
|
|||||||
CONSTRAINT attachments_object_key_len
|
CONSTRAINT attachments_object_key_len
|
||||||
CHECK (char_length(object_key) BETWEEN 1 AND 1024),
|
CHECK (char_length(object_key) BETWEEN 1 AND 1024),
|
||||||
CONSTRAINT attachments_status_chk
|
CONSTRAINT attachments_status_chk
|
||||||
CHECK (status IN ('ready', 'failed')),
|
CHECK (status IN ('ready', 'pending', 'failed')),
|
||||||
CONSTRAINT attachments_error_code_consistency
|
CONSTRAINT attachments_error_code_consistency
|
||||||
CHECK (
|
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)
|
(status = 'failed' AND error_code IS NOT NULL)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@@ -44,6 +44,10 @@ CREATE UNIQUE INDEX attachments_object_key_uniq
|
|||||||
CREATE INDEX attachments_chat_idx
|
CREATE INDEX attachments_chat_idx
|
||||||
ON attachments (chat_id, created_at, id);
|
ON attachments (chat_id, created_at, id);
|
||||||
|
|
||||||
|
CREATE INDEX attachments_pending_idx
|
||||||
|
ON attachments (created_at)
|
||||||
|
WHERE status = 'pending';
|
||||||
|
|
||||||
CREATE TABLE message_attachments (
|
CREATE TABLE message_attachments (
|
||||||
message_id UUID NOT NULL REFERENCES messages(id) ON DELETE CASCADE,
|
message_id UUID NOT NULL REFERENCES messages(id) ON DELETE CASCADE,
|
||||||
attachment_id UUID NOT NULL REFERENCES attachments(id) ON DELETE RESTRICT,
|
attachment_id UUID NOT NULL REFERENCES attachments(id) ON DELETE RESTRICT,
|
||||||
|
|||||||
Reference in New Issue
Block a user