1.2 KiB
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.sqlwith all 4 tables + indexescrates/post3/src/models.rs— BucketRow, ObjectRow, BlockRow, MetadataEntry, ObjectInfo, ListObjectsResultcrates/post3/src/error.rs— Post3Error enum (BucketNotFound, BucketAlreadyExists, ObjectNotFound, BucketNotEmpty, Database, Other)- Migration runs successfully against PostgreSQL
cargo check -p post3passes
Schema Details
buckets— id (UUID PK), name (TEXT UNIQUE), created_atobjects— 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)