forked from mtusi2026/mtusi2026lab5
lab5
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
-- Track 1 (grade 5): pending direct/presigned upload sessions.
|
||||
-- Attachment rows stay status=ready only; incomplete uploads live here.
|
||||
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) ON DELETE CASCADE,
|
||||
filename text NOT NULL
|
||||
CHECK (char_length(filename) BETWEEN 1 AND 255),
|
||||
content_type text NOT NULL
|
||||
CHECK (content_type IN ('image/png', 'image/jpeg')),
|
||||
expected_size integer NOT NULL
|
||||
CHECK (expected_size >= 1 AND expected_size <= 10485760),
|
||||
expected_sha256 text NOT NULL
|
||||
CHECK (expected_sha256 ~ '^[a-f0-9]{64}$'),
|
||||
s3_key text NOT NULL UNIQUE,
|
||||
status text NOT NULL
|
||||
CHECK (status IN ('pending', 'completed', 'aborted', 'expired')),
|
||||
attachment_id uuid NULL REFERENCES attachments(id),
|
||||
expires_at timestamptz NOT NULL,
|
||||
created_at timestamptz NOT NULL,
|
||||
updated_at timestamptz NOT NULL
|
||||
);
|
||||
|
||||
CREATE INDEX direct_uploads_status_expires_idx
|
||||
ON direct_uploads (status, expires_at);
|
||||
CREATE INDEX direct_uploads_owner_idx ON direct_uploads (owner_id);
|
||||
Reference in New Issue
Block a user