ЛР4: S3-вложения (SeaweedFS), приватный bucket, компенсация/reconciler, тесты, отчёт

This commit is contained in:
2026-11-06 17:11:20 +03:00
parent ec540a1a72
commit b25600adcc
62 changed files with 4196 additions and 19 deletions
+31
View File
@@ -0,0 +1,31 @@
-- Lab4 attachments: metadata in PostgreSQL, bytes in S3.
--
-- ``s3_key`` is server-generated and never exposed through the API. Linkage to
-- a message is a many-to-many table so a message can carry ordered attachments
-- and the same attachment can be referenced again without duplicating bytes.
create table if not exists attachments (
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 bigint not null,
sha256 text not null,
status text not null,
s3_key text not null,
error_code text,
created_at timestamptz not null,
updated_at timestamptz not null
);
create index if not exists attachments_chat_id_idx on attachments (chat_id);
create table if not exists message_attachments (
message_id uuid not null references messages (id) on delete cascade,
attachment_id uuid not null references attachments (id) on delete cascade,
position integer not null,
primary key (message_id, attachment_id)
);
create index if not exists message_attachments_attachment_idx
on message_attachments (attachment_id);