Implement durable image queue with outbox worker and recovery checks

This commit is contained in:
2026-11-21 11:56:57 +03:00
parent 276dbdad8a
commit 7909110924
52 changed files with 2658 additions and 48 deletions
+11
View File
@@ -0,0 +1,11 @@
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 TABLE attachments (
id uuid PRIMARY KEY, chat_id uuid NOT NULL REFERENCES chats(id),
uploader_id uuid NOT NULL REFERENCES users(id), object_key text UNIQUE NOT NULL,
filename text NOT NULL, content_type text NOT NULL, size_bytes bigint NOT NULL,
sha256 text NOT NULL, status text NOT NULL CHECK(status IN ('pending','ready')),
created_at timestamptz NOT NULL DEFAULT clock_timestamp()
);
CREATE INDEX attachments_pending_idx ON attachments(created_at) WHERE status='pending';