feat(lab5): implement reliable image pipeline and track 2

This commit is contained in:
sashadugina06
2026-11-20 18:43:47 +03:00
parent 276dbdad8a
commit b423b93e2a
62 changed files with 3799 additions and 38 deletions
+16
View File
@@ -0,0 +1,16 @@
CREATE TABLE attachments (
id UUID PRIMARY KEY,
chat_id UUID NOT NULL REFERENCES chats(id),
owner_id UUID NOT NULL REFERENCES users(id),
filename TEXT NOT NULL,
object_key TEXT NOT NULL UNIQUE,
size_bytes BIGINT NOT NULL CHECK (size_bytes BETWEEN 1 AND 10485760),
content_type TEXT NOT NULL CHECK (content_type IN ('image/png', 'image/jpeg')),
sha256 CHAR(64) NOT NULL,
status TEXT NOT NULL DEFAULT 'ready' CHECK (status = 'ready'),
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);
ALTER TABLE messages DROP CONSTRAINT messages_text_check;
ALTER TABLE messages ADD COLUMN attachment_ids UUID[] NOT NULL DEFAULT '{}';
ALTER TABLE messages ADD CHECK (length(text) <= 4000 AND (length(btrim(text)) > 0 OR cardinality(attachment_ids) > 0));