Skip to content

feat: adopt Prisma 7 with first migration, seed, and CI database gate — closes #14 - #19

Merged
mikim merged 2 commits into
mainfrom
feat/prisma-7
Jul 14, 2026
Merged

feat: adopt Prisma 7 with first migration, seed, and CI database gate — closes #14#19
mikim merged 2 commits into
mainfrom
feat/prisma-7

Conversation

@mikim

@mikim mikim commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

What

Completes M0 by replacing the schema-only database layer with a working Prisma 7 setup, proven against real Postgres in CI.

Closes #14

Key points

  • prisma.config.ts (v7): schema/migrations paths, tsx seed command, datasource URL with a docker-compose fallback so DB-less commands (prisma generate) work without .env. The datasource.url left schema.prisma per the v7 structure.
  • Generator switched to prisma-client with explicit output into packages/db/src/generated (gitignored, regenerated by pnpm db:generate), ESM + NodeNext-compatible import extensions. Compiles clean under the repo's strict TS project-references build.
  • packages/db: createPrismaClient() backed by @prisma/adapter-pg — v7 has no Rust query engine, the driver adapter is mandatory.
  • First migration generated offline (prisma migrate diff --from-empty --to-schema; no local Docker on the dev machine) — CI proves it by running prisma migrate deploy against a postgres:17 service container.
  • Idempotent seed (fixed-id upserts): demo user, goal, source, 2 study units.
  • scripts/smoke-db.mjs: built client ↔ migrated DB — seed presence + a create/delete write round-trip.
  • CI order: generate → lint → typecheck → test → build → migrate deploy → seed → db smoke → api smoke.
  • pnpm 11 allowBuilds approvals for prisma engines postinstall; .env.example + docker-compose.yml.

Verified locally (no DB available locally)

lint / typecheck / 26 tests / build / API smoke ✅ — the migration apply + db smoke are exactly what the CI Postgres service exists to verify.

🤖 Generated with Claude Code

mikim and others added 2 commits July 14, 2026 16:49
Complete the last M0 item: the schema-only database layer becomes a
working Prisma 7 setup, verified against real Postgres in CI.

- prisma.config.ts (Prisma 7): schema/migrations paths, tsx seed
  command, datasource URL with a docker-compose fallback so DB-less
  commands (prisma generate) work without a .env
- schema.prisma: switch generator to `prisma-client` with explicit
  output into packages/db/src/generated, ESM + NodeNext-compatible
  import extensions; datasource url moved out of the schema (v7)
- packages/db: new workspace package exposing createPrismaClient()
  backed by @prisma/adapter-pg (v7 has no Rust engine; the driver
  adapter is mandatory); generated client is gitignored and rebuilt
  via `pnpm db:generate`
- First migration generated offline via `prisma migrate diff
  --from-empty --to-schema` (no local Docker available) — CI proves it
  by running `prisma migrate deploy` against a postgres:17 service
- Idempotent seed (upserts by fixed ids): demo user, goal, source,
  2 study units
- scripts/smoke-db.mjs: connects the BUILT client to the migrated DB,
  checks seed presence, and does a create/delete write round-trip
- CI: postgres:17 service with healthcheck; generate -> lint ->
  typecheck -> test -> build -> migrate deploy -> seed -> db smoke ->
  api smoke
- .env.example, docker-compose.yml (postgres:17), root db:* scripts
- pnpm allowBuilds for prisma/@prisma/engines postinstall
- README: database rows/sections updated; M0 marked complete

Closes #14

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…reaking top-level await

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@mikim
mikim merged commit ccb0db1 into main Jul 14, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

P0: Adopt Prisma 7 and establish first migration

1 participant