Replies: 3 comments 2 replies
|
The Solution: 1. For Prisma 5.x+, use datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
schemas = ["my_web_schema"]
}
generator client {
provider = "prisma-client-js"
previewFeatures = ["multiSchema"]
}
model User {
id Int @id
name String
@@schema("my_web_schema")
}2. Update your connection string (remove the schema param): 3. Regenerate the client: npx prisma generate
npx prisma db pushAlternative: Use This sets the default schema for all queries. Docs: https://www.prisma.io/docs/orm/prisma-schema/data-model/multi-schema |
|
You seem to be running into this issue, can you try out the solution mentioned here and confirm if it fixes the issue for you? |
|
This is a well-known Prisma + PostgreSQL schema routing issue, and the behavior you're describing — Why this happens — two separate mechanisms control schema routing
The core issue is that when you have multiple query parameters in a PostgreSQL connection string, certain parameter combinations cause the URL parser to silently drop or misread one of them. In your case: The The fix — set
|
| Approach | Fixes migrate? | Fixes runtime queries? | Reliability |
|---|---|---|---|
?schema=my_web_schema alone |
✅ | Unreliable with multiple query params | |
?schema= + options=-c search_path= |
✅ | ✅ | Reliable — driver-level |
schemas = ["my_web_schema"] in datasource + multiSchema |
✅ | ✅ | Recommended for Prisma 7.x |
@@schema("my_web_schema") on models |
✅ | ✅ | Required alongside multiSchema |
Use the multiSchema datasource declaration approach — it is the correct, idiomatic Prisma 7.x solution for non-public schema routing and resolves both the migration and runtime query issues permanently.
Hope this helps — if it answers your question, would you mind clicking "Mark as answer" so others searching for the same thing can find it quickly?
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Question
for my pgsql db, I have make the ssl enable, and then I found it always make error, so I have found the solution like this one
here below to disable the ssl verification:
#28803
but the issue is when I make the connection string into like this one:
DATABASE_URL="postgresql://USER:DATABASE_PASSWORD@HOST:PORT/DATABASE?schema=my_web_schema&sslmode=no-verify"as my schema of the
my_web_schemaindeed existed in my db and the table of the User have been created as well, but why does it will always use the default schema of thepubliclike below?but with the same string , when I run the commend of the
npx prisma migrate, with the same string, it indeed can create the table of the User in the specified schema of themy_web_schema, but why ?also here are what I use of the prisma version:
prisma: 7.2.0
postgresql: 18
All reactions