Перенести рабочую базу lab4 в skeleton лабораторной 5.

Исходники, миграции, Dockerfile и стенд lab4 нужны как основа асинхронной обработки вложений.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-11-09 00:48:22 +03:00
co-authored by Cursor
parent 276dbdad8a
commit 9046d5206d
40 changed files with 4136 additions and 0 deletions
+22
View File
@@ -0,0 +1,22 @@
-- Optional presigned upload. The signed URL dies quickly. The row stays pending
-- until complete checks the object that actually landed in the bucket.
-- Incomplete rows are aborted by the same grace sweeper as other uncommitted keys.
CREATE TABLE direct_uploads (
id UUID PRIMARY KEY,
chat_id UUID NOT NULL REFERENCES chats (id) ON DELETE CASCADE,
owner_id UUID NOT NULL REFERENCES users (id),
filename TEXT NOT NULL,
content_type TEXT NOT NULL,
size_bytes INTEGER NOT NULL,
object_key TEXT NOT NULL UNIQUE,
status TEXT NOT NULL,
expires_at TIMESTAMPTZ NOT NULL,
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
CONSTRAINT direct_uploads_filename_len CHECK (char_length(filename) BETWEEN 1 AND 255),
CONSTRAINT direct_uploads_size CHECK (size_bytes BETWEEN 1 AND 10485760),
CONSTRAINT direct_uploads_type CHECK (content_type IN ('image/png', 'image/jpeg')),
CONSTRAINT direct_uploads_status CHECK (status IN ('pending', 'completed', 'aborted'))
);
CREATE INDEX direct_uploads_pending_idx ON direct_uploads (expires_at) WHERE status = 'pending';