Skip to content

ORM config paths resolve against the file that declared them - #30128

Draft
wmadden-electric wants to merge 1 commit into
mainfrom
config-declaring-file-paths
Draft

ORM config paths resolve against the file that declared them#30128
wmadden-electric wants to merge 1 commit into
mainfrom
config-declaring-file-paths

Conversation

@wmadden-electric

@wmadden-electric wmadden-electric commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

What this changes

The unified CLI now discovers prisma.config.ts from the working directory up to the repo root and merges every file it finds, one key at a time. That means an orm section declared in, say, packages/db/prisma.config.ts now reaches a command run from the repo root — and resolving that section's ./migrations or ./contract.json against the working directory pointed at the wrong directory.

@prisma/cli-engine 0.3.0 gives a section validator the provenance of the value it validates: which file on the chain declared each top-level key. The orm section validator now uses it.

  • contract.source.inputs, contract.output and migrations.dir resolve against the directory of the config file that declared contract or migrations. When those two keys come from different files on the chain, each resolves against its own file.
  • An absent migrations still defaults to migrations/, but now beside the nearest declaring file rather than beside the caller.
  • Absolute paths pass through untouched.
  • Because the validator now returns absolute paths, defineOrmCommand no longer re-resolves the config it hands a handler. Its cwd-anchored finalizeConfig call is gone.
  • loadOrmConfig returns the engine's new config shape — a chain of files rather than one file. This repo's bin reads a single prisma.config.ts, so the chain holds that one file and every key's provenance names it.
  • @internal/config-loader now exports finalizeContractConfig and finalizeMigrationsConfig, the two halves of finalizeConfig the validator needs to resolve each key against its own directory.

Verification

@prisma/cli-engine 0.3.0 is not on npm yet, so this was verified against a locally packed 0.3.0 tarball wired in through a temporary pnpm override. The override and its lockfile churn were reverted before committing; the diff pins nothing new.

Against the real 0.3.0 build:

  • @internal/cli: pnpm typecheck clean (source and tests), pnpm test 1442 tests in 115 files, all passing.
  • @internal/config-loader: pnpm typecheck clean, 46 tests passing.
  • pnpm lint:deps, pnpm check:conformance and biome check on the changed trees: clean.
  • pnpm test:packages across the whole workspace: 1172 of 1176 test files pass. The failures are covered below.

This does not go green yet

Two things have to happen before CI can pass, and neither belongs in this PR.

1. @prisma/cli-engine 0.3.0 has to publish (prisma/prisma-cli#233). Until then the pin stays at 0.2.3, where SectionProvenance does not exist and the engine calls validate with one argument. The change is inert and red either way, which is why this is a draft.

2. The repo has to stop importing defineConfig. 0.3.0 removes the deprecated defineConfig alias from @prisma/cli-engine. 306 files in this repo — mostly test fixtures and example prisma.config.ts files — still imported it, and they fail at runtime under 0.3.0 with defineConfig is not a function. That is what the two @internal/cli-telemetry failures in the run above are.

#30129 is the prerequisite for this PR and does that rename. It is mergeable today: definePrismaConfig has existed since engine 0.2.0, and on the pinned 0.2.3 the two names are the same function object, so the sweep is behaviour-neutral. Merge #30129, then move the pin, then this PR goes green.

The other two failures in that run are unrelated: @prisma/orm-framework's module-identity test tripped over a leftover gitignored skills/prisma-8 directory, and one @internal/adapter-postgres planner test failed under parallel load and passes on its own.

Follow-up worth noting

finalizeConfig in @internal/config-loader now has no production caller — only its own tests. It resolves an entire config against a single directory, which is exactly the behaviour this PR removes. Deleting it (and its test file) is a reasonable cleanup, left out here to keep the diff readable.

🤖 Generated with Claude Code

The unified CLI now discovers `prisma.config.ts` from the working directory up to the repo root and merges the files it finds, one key at a time. An `orm` section declared in `packages/db` therefore reaches a command run from the repo root — and resolving that section's `./migrations` or `./contract.json` against the working directory pointed at the wrong place.

`@prisma/cli-engine` 0.3.0 hands a section validator the provenance of the value it validates: which file declared each top-level key. The `orm` section validator now uses it. `contract.source.inputs`, `contract.output` and `migrations.dir` resolve against the directory of the file that declared `contract` or `migrations`, each against its own file when the two came from different files. An absent `migrations` still defaults to `migrations/`, now beside the nearest declaring file rather than beside the caller. Absolute paths pass through untouched.

Because the validator now returns absolute paths, `defineOrmCommand` no longer re-resolves the config it hands a handler, and its cwd-anchored `finalizeConfig` call is gone.

`loadOrmConfig` returns the engine's new config shape: a chain of files rather than one file. This repo's bin reads a single `prisma.config.ts`, so the chain it returns holds that one file, and every key's provenance names it.

`@internal/config-loader` now exports `finalizeContractConfig` and `finalizeMigrationsConfig`, the two halves of `finalizeConfig` the validator needs to resolve each key against its own directory.

This needs `@prisma/cli-engine` 0.3.0, which is not published yet (prisma/prisma-cli#233), so the repo's checks stay red until the engine pin moves off 0.2.3.

Signed-off-by: willbot <w.a.madden+machine@gmail.com>
Signed-off-by: Will Madden <madden@prisma.io>
@coderabbitai

coderabbitai Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@pkg-pr-new

pkg-pr-new Bot commented Aug 25, 2026

Copy link
Copy Markdown

Open in StackBlitz

@prisma/orm-extension-arktype-json

npm i https://pkg.pr.new/@prisma/orm-extension-arktype-json@30128

@prisma/orm-extension-middleware-cache

npm i https://pkg.pr.new/@prisma/orm-extension-middleware-cache@30128

@prisma/orm-extension-paradedb

npm i https://pkg.pr.new/@prisma/orm-extension-paradedb@30128

@prisma/orm-extension-pgvector

npm i https://pkg.pr.new/@prisma/orm-extension-pgvector@30128

@prisma/orm-extension-postgis

npm i https://pkg.pr.new/@prisma/orm-extension-postgis@30128

@prisma/orm-extension-supabase

npm i https://pkg.pr.new/@prisma/orm-extension-supabase@30128

@prisma/orm-family-mongo

npm i https://pkg.pr.new/@prisma/orm-family-mongo@30128

@prisma/orm-family-sql

npm i https://pkg.pr.new/@prisma/orm-family-sql@30128

@prisma/orm-framework

npm i https://pkg.pr.new/@prisma/orm-framework@30128

@prisma/orm-mongo

npm i https://pkg.pr.new/@prisma/orm-mongo@30128

@prisma/orm-postgres

npm i https://pkg.pr.new/@prisma/orm-postgres@30128

@prisma/orm-sqlite

npm i https://pkg.pr.new/@prisma/orm-sqlite@30128

@prisma/orm-target-mongo

npm i https://pkg.pr.new/@prisma/orm-target-mongo@30128

@prisma/orm-target-postgres

npm i https://pkg.pr.new/@prisma/orm-target-postgres@30128

@prisma/orm-target-sqlite

npm i https://pkg.pr.new/@prisma/orm-target-sqlite@30128

@prisma/orm-toolchain

npm i https://pkg.pr.new/@prisma/orm-toolchain@30128

commit: 0c07748

@github-actions

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size
postgres / no-emit 174.86 KB (0%)
postgres / emit 152.08 KB (0%)
mongo / no-emit 101.09 KB (0%)
mongo / emit 90.95 KB (0%)
cf-worker / no-emit 198.74 KB (0%)
cf-worker / emit 173.36 KB (0%)

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.

2 participants