feat: adopt Prisma 7 with first migration, seed, and CI database gate — closes #14 - #19
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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,tsxseed command, datasource URL with a docker-compose fallback so DB-less commands (prisma generate) work without.env. Thedatasource.urlleftschema.prismaper the v7 structure.prisma-clientwith explicit output intopackages/db/src/generated(gitignored, regenerated bypnpm 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.prisma migrate diff --from-empty --to-schema; no local Docker on the dev machine) — CI proves it by runningprisma migrate deployagainst apostgres:17service container.scripts/smoke-db.mjs: built client ↔ migrated DB — seed presence + a create/delete write round-trip.allowBuildsapprovals 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