# ADR 0003 — Drizzle as schema source of truth

**Status:** Accepted (2026-05-06)

## Context

The Oshun monorepo has a cross-domain contract suite that requires every domain
to publish a Prisma schema artifact for shape alignment. The Arete domain
originally complied with a single 44-line `Practice` model in
`libs/arete/database/prisma/schema.prisma` while the actual runtime schema lived
in `libs/arete/core/src/db-schema.ts` (Drizzle).

This dual-schema state is a footgun: every new table must be added in both
places, and any drift quietly breaks the contract test on the next PR.

## Decision

Drizzle (`libs/arete/core/src/db-schema.ts`) is the authoritative schema for
everything Arete persists.

- New tables go into the Drizzle file. They do **not** get added to the Prisma
  schema.
- The Prisma schema retains only the `Practice` model — required by the
  cross-domain contract auditor — and a header comment documenting the rule.
- Repository implementations import Drizzle table objects directly
  (`import { areteUsers } from '@arete/core'`).

If a future cross-domain feature requires a new model exposed in Prisma, we add
it to the Prisma schema **and** to the Drizzle schema, and add a schema spec
assertion to `db-schema.spec.ts` that the column lists match.

## Consequences

- One canonical place to look for table shape — the spec test
  (`db-schema.spec.ts`) covers all 48 tables.
- Migrations are generated by `pnpm drizzle-kit generate:pg` against the Drizzle
  schema, which means new tables come with proper indexes and FK cascades by
  default.
- The contract auditor (`libs/contracts/src/common/contract-prisma-*`) still
  passes because the Practice model stays in place.

## Reference

- Schema: `libs/arete/core/src/db-schema.ts`
- Spec: `libs/arete/core/src/db-schema.spec.ts`
- Prisma sentinel: `libs/arete/database/prisma/schema.prisma`
