| 1 | CREATE TABLE uploads ( |
| 2 | id uuid PRIMARY KEY, |
| 3 | owner_id text NOT NULL, |
| 4 | object_key text NOT NULL UNIQUE, |
| 5 | filename text NOT NULL, |
| 6 | content_type text NOT NULL, |
| 7 | expected_bytes bigint NOT NULL CHECK (expected_bytes BETWEEN 1 AND 10485760), |
| 8 | actual_bytes bigint, |
| 9 | status text NOT NULL DEFAULT 'awaiting_upload' |
| 10 | CHECK (status IN ('awaiting_upload', 'ready', 'rejected')), |
| 11 | created_at timestamptz NOT NULL DEFAULT now(), |
| 12 | processed_at timestamptz |
| 13 | ); |
| 14 | CREATE INDEX uploads_owner_created ON uploads (owner_id, created_at DESC); |
| 15 | CREATE TABLE upload_events ( |
| 16 | invocation_id text PRIMARY KEY, |
| 17 | object_key text NOT NULL, |
| 18 | processed_at timestamptz NOT NULL DEFAULT now() |
| 19 | ); |