Files
post3/todos/POST3-002-schema-models-errors.md
2026-02-27 11:38:10 +01:00

1.2 KiB

POST3-002: Database schema, models, and error types

Status: Done Priority: P0 Blocked by: POST3-001

Description

Define the PostgreSQL schema (buckets, objects, object_metadata, blocks), create Rust model types with sqlx::FromRow, and define the Post3Error enum.

Acceptance Criteria

  • crates/post3/migrations/20260226000001_initial.sql with all 4 tables + indexes
  • crates/post3/src/models.rs — BucketRow, ObjectRow, BlockRow, MetadataEntry, ObjectInfo, ListObjectsResult
  • crates/post3/src/error.rs — Post3Error enum (BucketNotFound, BucketAlreadyExists, ObjectNotFound, BucketNotEmpty, Database, Other)
  • Migration runs successfully against PostgreSQL
  • cargo check -p post3 passes

Schema Details

  • buckets — id (UUID PK), name (TEXT UNIQUE), created_at
  • objects — id (UUID PK), bucket_id (FK CASCADE), key, size, etag, content_type, created_at; unique on (bucket_id, key)
  • object_metadata — id (UUID PK), object_id (FK CASCADE), meta_key, meta_value; unique on (object_id, meta_key)
  • blocks — id (UUID PK), object_id (FK CASCADE), block_index, data (BYTEA), block_size; unique on (object_id, block_index)