feat(lab4): MinIO S3 private bucket, streaming image validation, attachment endpoints, Grade 5 Track 2 reconciler

This commit is contained in:
2026-11-17 02:55:14 +03:00
parent ec540a1a72
commit eaf3963e05
33 changed files with 8458 additions and 21 deletions
+17
View File
@@ -0,0 +1,17 @@
-- Migration 002: Idempotency keys for POST /api/v1/chats/{chat_id}/messages (Lab 3)
-- Scope: (user_id, chat_id, idempotency_key), TTL 24h by default.
-- Message creation and idempotency key registration happen atomically in one PostgreSQL transaction.
CREATE TABLE IF NOT EXISTS idempotency_keys (
user_id UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE,
chat_id UUID NOT NULL REFERENCES chats(id) ON DELETE CASCADE,
idempotency_key VARCHAR(128) NOT NULL
CONSTRAINT chk_idempotency_key_format CHECK (idempotency_key ~ '^[A-Za-z0-9._:-]{1,128}$'),
request_hash CHAR(64) NOT NULL,
message_id UUID NOT NULL REFERENCES messages(id) ON DELETE CASCADE,
created_at TIMESTAMPTZ NOT NULL,
expires_at TIMESTAMPTZ NOT NULL,
PRIMARY KEY (user_id, chat_id, idempotency_key)
);
CREATE INDEX IF NOT EXISTS idx_idempotency_keys_expires_at ON idempotency_keys (expires_at);