Repository navigation
fix(prisma): inherit database region from the project's default region - #2026
Open
kristof-siket wants to merge 1 commit into
Open
kristof-siket wants to merge 1 commit into
kristof-siket wants to merge 1 commit into
Conversation
A database with `region: "inherit"` now takes the project's `defaultRegion` from the Management API. It falls back to the default database's region only when the project has no default region. Before, alchemy used only the default database, so a project without one could not deploy inherited databases, and promoting a default database in another region planned a replacement of every inherited database. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
kristof-siket
marked this pull request as ready for review
October 6, 2026 10:16
Contributor
|
Install the packages built from this commit: alchemypnpm install https://pkg.alchemy.run/alchemy/pr:2026:c7b8089@alchemy.run (6)pnpm install https://pkg.alchemy.run/@alchemy.run/better-auth/pr:2026:c7b8089pnpm install https://pkg.alchemy.run/@alchemy.run/cloudflare-runtime/pr:2026:c7b8089pnpm install https://pkg.alchemy.run/@alchemy.run/frontend-frameworks/pr:2026:c7b8089pnpm install https://pkg.alchemy.run/@alchemy.run/node-utils/pr:2026:c7b8089pnpm install https://pkg.alchemy.run/@alchemy.run/floci/pr:2026:c7b8089pnpm install https://pkg.alchemy.run/@alchemy.run/pkg/pr:2026:c7b8089@distilled.cloud (16)pnpm install https://pkg.alchemy.run/@distilled.cloud/core/pr:2026:c7b8089pnpm install https://pkg.alchemy.run/@distilled.cloud/acme/pr:2026:c7b8089pnpm install https://pkg.alchemy.run/@distilled.cloud/aws/pr:2026:c7b8089pnpm install https://pkg.alchemy.run/@distilled.cloud/axiom/pr:2026:c7b8089pnpm install https://pkg.alchemy.run/@distilled.cloud/cloudflare/pr:2026:c7b8089pnpm install https://pkg.alchemy.run/@distilled.cloud/doppler/pr:2026:c7b8089pnpm install https://pkg.alchemy.run/@distilled.cloud/fly-io/pr:2026:c7b8089pnpm install https://pkg.alchemy.run/@distilled.cloud/github/pr:2026:c7b8089pnpm install https://pkg.alchemy.run/@distilled.cloud/hetzner/pr:2026:c7b8089pnpm install https://pkg.alchemy.run/@distilled.cloud/infisical/pr:2026:c7b8089pnpm install https://pkg.alchemy.run/@distilled.cloud/neon/pr:2026:c7b8089pnpm install https://pkg.alchemy.run/@distilled.cloud/prisma/pr:2026:c7b8089pnpm install https://pkg.alchemy.run/@distilled.cloud/planetscale/pr:2026:c7b8089pnpm install https://pkg.alchemy.run/@distilled.cloud/railway/pr:2026:c7b8089pnpm install https://pkg.alchemy.run/@distilled.cloud/stripe/pr:2026:c7b8089pnpm install https://pkg.alchemy.run/@distilled.cloud/zerossl/pr:2026:c7b8089Published |
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.
Why
The Prisma Management API returns a
defaultRegionon every project. When it creates a database withregion: "inherit", the server uses that project region. It falls back to the default database's region only when the project has none.Prisma.Databaseresolved"inherit"on the client and ignored the project region. It used only the region of the project's default database. This causes two problems today:region: "inherit". The deploy fails with "Cannot resolve Prisma database region 'inherit' because project ... has no default database region". Prisma Composer creates every database with"inherit", so these projects cannot deploy Composer apps. Users have to create a placeholder default database by hand.What changed
resolveDatabaseRegioninPrisma/Database.tsreads the project withgetProject. It returnsdefaultRegionwhen it is not null.defaultRegionis null, it uses the default database's region as before. The error for multiple default databases is unchanged.regionJSDoc describes what"inherit"does.Plan (
diff) andreconcileboth use this function, so they resolve the same region.Other providers do not resolve
"inherit"on the client.Prisma.AppandPrisma.Computeleave the region out when it is not set, and the server picks the project region.Prisma.Buckethas no region prop. The local dev provider forPrisma.Databasedoes not call the API, so it is not changed.Tests
New unit tests in
test/Prisma/ManagementLifecycle.test.tsrun against the in-memory Management API:The existing test for the fallback to the default database still passes. I renamed it to say what it tests.
Ran locally:
pnpm test test/Prisma/ManagementLifecycle.test.ts: 19 passed. The two new tests fail onmain.pnpm test test/Prisma: 408 passed, 10 skipped. The 34 failures are live tests that need Prisma or Neon credentials. One Next.js artifact test timed out under load and passes alone.pnpm tsc -b,pnpm format:check,pnpm lint:providers,pnpm docs:check-jsdoc, andoxlinton the changed files pass.I did not run the live Prisma tests, because they need credentials.
Compatibility
Projects without a
defaultRegionbehave exactly as before. For projects that have one, the API already falls back to the default database's region in that field, so the result matches today's in the common case. The result changes only when the project region differs from the default database's region. In that case alchemy now matches what the server does for"inherit".🤖 Generated with Claude Code