Skip to content

002 — Drizzle ORM

Context

The server needs typed queries, migrations, and partial unique indexes expressed near the schema (apps/server/src/db/schema.ts), on top of D1/SQLite.

Decision

Use Drizzle (code-first) instead of raw SQL-only access or a heavier ORM. Repositories own query composition; services stay domain-focused.

Consequences

  • Schema and TypeScript types stay in sync.
  • D1 batch is used for atomic claim transfer and related multi-statement updates.
  • SQLite/D1 dialect specifics leak into repositories — acceptable given ADR 001.