- pnpm 10 workspace + TypeScript strict + ESLint flat + Prettier - CLAUDE.md as canonical brief - docs/tasks/ — 22 task briefs broken out by phase for sub-sessions - docs/decisions/ — ADR scaffold Implements task 01 (repo-init).
1.5 KiB
1.5 KiB
03 — Drizzle + Postgres setup
Goal
Wire Drizzle ORM to a Postgres 16 instance, with migrations and a working db client.
Depends on
- 02 (Next.js skeleton)
Scope
- Install
drizzle-orm,drizzle-kit,postgres(thepostgresdriver, notpg). drizzle.config.tspointing atsrc/modules/**/schema.tsand writing to./drizzle/.src/lib/db.tsexporting a singletondbclient built fromDATABASE_URL.- Initial schema in
src/modules/_core/schema.ts:users(id uuid pk, email unique, display_name, created_at)households(id uuid pk, name, created_at)household_members(household_id, user_id, role enum:owner|member, pk on both)
- pnpm scripts:
db:generate,db:migrate,db:studio. docker-compose.dev.yamlat repo root with afamapp-dbservice for local dev (Postgres 16, exposed on 5432, named volume).
Out of scope
- Module-specific tables (calendar/lists/notes ship in their own tasks).
- Seed data (in task 07).
Acceptance criteria
docker compose -f docker-compose.dev.yaml up -dstarts Postgres locally.pnpm db:generate && pnpm db:migrateproducesdrizzle/0000_*.sqland applies it.- A throwaway script can
import { db } from "@/lib/db"andselectfromusers(returning empty). tsc --noEmitpasses.
Notes
- Use the
postgresdriver — works in both Node and edge-light contexts and is what Drizzle docs prefer for serverless-shaped apps. - Keep the dev compose file separate from the production
deploy/compose.yaml(task 05).