Exercise: Drizzle Teams CRUD + migrations
Goal
Practice the “real” backend slice:
- define schema (tables)
- generate/apply migrations
- implement CRUD behind tRPC procedures
Scenario
Implement a teams table with:
id(primary key)name(string, required)createdAt(timestamp)
Then implement:
- list teams
- create team
- rename team
- delete team
Requirements
- Schema lives in a server-only module.
- Migrations are generated and applied (Drizzle Kit).
- tRPC procedures validate input with Zod.
Acceptance criteria (entry)
- DB schema is the source of truth (no “fake” in-memory list).
- Invalid inputs are rejected before DB calls.
- UI updates correctly after mutations.
Stretch goals (mid)
- Add a unique constraint on
nameand map the DB error to a friendly UI message. - Add a procedure test that mocks the DB layer.
Stretch goals (senior)
- Document how you’d organize schema/migrations in a multi-app monorepo (even if we’re single-app now).
Last updated on