You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Right now with Prisma, you can query across one schema at a time but in many cases, you need to query across multiple tables stored across multiple database schemas.
We need to make certain product decision to enable this like how we are going to add this schema metadata information to the model and other implementation details that are necessary to be handled for this.
Reacted by André Abreu, Fábio Santos, David Roncancio, Marko Stijak, Kush, Oriel Vinci Absin, Maksis Libeks, Wendell Misiedjan, phiresky, Nikolai Kolodziej and 317 more
Reacted by Domagoj Vukovic, Max Antony, David Vaness, Philip Hickey, Stefan Stellar, Okan YILDIRIM, Nicolas CAMILLI, Mason Williams, Bernat Fogarasi, Shaunak Vairagare and 22 more
Reacted by Muhammad Rehan Qadri, Yasuyuki Matsumoto, Mateus Zitelli, Heyda Han, Alexandra Baduna, CJ Lazell, Ryoji Miyazato, Viacheslav Shuianov, AleksandrukTad, Hyo and 68 more
Reacted by Tyler Clendenin, Nick Kang, Gilles Coomans, Peter, Michael Li, sundeer, Amit Anand, Christoph Dalski, Rodolfo Silva, Pavel Krčmář and 37 more
Reacted by h3us, Rodolfo Silva, Mayrom, Miladiir, Pavel Krčmář, Max Heinritz, James Qualls, Hadi, Félix Gómez, Tom Gallacher and 38 more
@pantharshit00 are there any plans to support this going forward? I might be misunderstanding things but is my understanding correct that Prisma currently only supports connecting to a single PostgreSQL schema?
In our database, we have tables and views split across multiple schemas that we need to be able to pull data from. We really want to use Prisma, but until there is support for connecting to multiple schemas in the same DB, it will not be possible for us to do so.
Reacted by Nick Kang, Julio-Assis, Michał Gajek, Alon b, Mortifia, Bernat Vadell, Anton Kashirov, Yahya Gilany, AglaiaMedia, Benjamin Sanglitan and 42 more
+1 for that. This item has been open for too long. I too use multiple schemas in a single project and in order to migrate completely to Prisma, this is a must.
Reacted by haroldwaste, slavicdev34, Sébastien Vanvelthem, Bernat Vadell, Nick Kang, Yahya Gilany, kpdud, Benjamin Sanglitan, Jacob Ley, Craig Pryde and 33 more
I am just getting into building multi-tenant apps. I plan to isolate tenants with schemas. There is a shared schema where a new tenant's data is stored, a script then runs on insert to create a schema for that tenant. A subdomain would be issued to the tenant and it would be the same as their schema name. Having a way to select which schema to query from would be nice.
Reacted by Guilherme Fernandes, Marcos Kuchak, Ketill Antoníus Ágústsson, Subramanya Chakravarthy and Niels
I am just getting into building multi-tenant apps. I plan is to isolate tenants with schemas. There is a shared schema where a new tenant's data is stored, a script then runs on insert to create a schema for that tenant. A subdomain would be issued to the tenant and it would be the same as their schema name. Having a way to select which schema to query from would be nice.
I'm facing the same situation. Were you able to solve it in any way using Prisma?
I am just getting into building multi-tenant apps. I plan is to isolate tenants with schemas. There is a shared schema where a new tenant's data is stored, a script then runs on insert to create a schema for that tenant. A subdomain would be issued to the tenant and it would be the same as their schema name. Having a way to select which schema to query from would be nice.
I'm facing the same situation. Were you able to solve it in any way using Prisma?
It just didn't work with Prisma, I ended up using Postgres.js and converting a bunch of Prisma queries to SQL. If you're using Postgres then Postgres.js will be your best bet.
generator client {
provider = "prisma-client-js"
previewFeatures = ["multiSchema"]
}
datasource db {
provider = "postgresql"
url = env("APP_DATABASE_URL")
schemas = ["base"]
}
datasource db {
provider = "mongodb"
url = env("TRANSACTIONAL_DATABASE_URL")
schemas = ["transactional"]
}
model User {
id Int @id
orders Order[]
@@schema("base")
}
model Order {
id Int @id
user User @relation(fields: [id], references: [id])
user_id Int
@@schema("transactional")
}
enum Size {
Small
Medium
Large
@@schema("transactional")
}
My use case for multiple schemas is a schema per git branch. When I a dev pushes into an feature branch, it builds and deploys at .mydomain.com . To segregate the database I use schema= in the postgres url. Works great in every hosted postgres I've tried. It works great with cockroach db. However, Prisma's hosted postgres completely ignores both the schema= connect string and the / and always uses the "postgres" database and "public" schema.
I attempted to work around the problem with:
schemas = [env("ACTIVE_SCHEMA")]
No dice (error: Expected a string value, but received functional value env("ACTIVE_SCHEMA").
--> prisma/schema.prisma:11)
Another use case I came across is the use of a schema for different organizations as part of an enterprise multi-tenancy strategy. This of course works perfectly fine with &schema=orgIfOfSomeSort but fails miserably with Prisma's hosted postgres.
Further development on this feature would be greatly appreciated. We are developing a quite huge monolith and want to seperate different scopes in different schemas, but it would be a pain without the capability to migrate.
This not only makes the db more structured, but we could also give other services read-only access to some of the schemas without the need to specify every single table the role should have access to.
@kokokenada thank you for your feedback! We are considering this for our work to move the multiSchema preview feature to GA.
Regarding Prisma Postgres: I am talking with our team working on this area whether we can make this work for native Prisma connections. In the meantime you can try to use direct TCP connections to Prisma Postgres. Based on my testing they support the schema=... query param as expected.
Could you please elaborate what your use case is to use multiple schemas with SQLite? 🤔
Yes, of course. I'm mostly looking at keeping separate schemas for different tables in my database, similar to a public schema in postgres and then, say, auth schema with user-account tables. I do have a setup in my project where we use postgres in prod and sqlite in dev with the help of prismaSchemaFolder as outlined in this discussion, but the only issue now is that I'm unable to make use of @@schema in local dev environment for sqlite. Again, multi-schema workaround aside, I'm looking to keep schemas separate in my database between public and auth for now.
With today's release of Prisma 6.13.0 we are moving multi schema support to general availability for Postgres and SQL Server. 🎉
We are hence closing this issue as completed.
Please note that multiple databases schemas for SQLite and MySQL are not supported and not on our current roadmap. Both databases work fundamentally different regarding schemas and demand for multi schema on them has been very low.
If you encounter issues with the multi schema feature please open fresh issues.
Reacted by Subramanya Chakravarthi, Grzegorz Widła, Guillaume Quittet, Toni Villena, Diego Barros, David Vins, 小木子, Jens-Rydholm-Humly, Harald Wartig and Phil Rukin
Activity
slavicdev34 commentedon Jul 4, 2020
Hi @pantharshit00 do you have any update about this issue?
pantharshit00 commentedon Jul 5, 2020
Sorry, there are no updates on this right now.
tylerben commentedon Aug 11, 2020
@pantharshit00 are there any plans to support this going forward? I might be misunderstanding things but is my understanding correct that Prisma currently only supports connecting to a single PostgreSQL schema?
In our database, we have tables and views split across multiple schemas that we need to be able to pull data from. We really want to use Prisma, but until there is support for connecting to multiple schemas in the same DB, it will not be possible for us to do so.
alonbilu commentedon Oct 21, 2020
+1 for that. This item has been open for too long. I too use multiple schemas in a single project and in order to migrate completely to Prisma, this is a must.
199 remaining items
meshackm commentedon Apr 13, 2024
I am just getting into building multi-tenant apps. I plan to isolate tenants with schemas. There is a shared schema where a new tenant's data is stored, a script then runs on insert to create a schema for that tenant. A subdomain would be issued to the tenant and it would be the same as their schema name. Having a way to select which schema to query from would be nice.
mkuchak commentedon Aug 2, 2024
I'm facing the same situation. Were you able to solve it in any way using Prisma?
meshackm commentedon Aug 3, 2024
It just didn't work with Prisma, I ended up using Postgres.js and converting a bunch of Prisma queries to SQL. If you're using Postgres then Postgres.js will be your best bet.
JoelWekesa commentedon Sep 14, 2024
When is this moving from preview? It's been in preview for quite some time
jordanskole commentedon Sep 23, 2024
Will this work across databases as well?
For example...
ineshbose commentedon Dec 20, 2024
Could it be possible to provide a possible port for this in sqlite, using ATTACH DATABASE?
kokokenada commentedon Mar 31, 2025
My use case for multiple schemas is a schema per git branch. When I a dev pushes into an feature branch, it builds and deploys at .mydomain.com . To segregate the database I use schema= in the postgres url. Works great in every hosted postgres I've tried. It works great with cockroach db. However, Prisma's hosted postgres completely ignores both the schema= connect string and the / and always uses the "postgres" database and "public" schema.
I attempted to work around the problem with:
schemas = [env("ACTIVE_SCHEMA")]
No dice (error: Expected a string value, but received functional value
env("ACTIVE_SCHEMA").--> prisma/schema.prisma:11)
kokokenada commentedon Apr 11, 2025
Another use case I came across is the use of a schema for different organizations as part of an enterprise multi-tenancy strategy. This of course works perfectly fine with &schema=orgIfOfSomeSort but fails miserably with Prisma's hosted postgres.
lookto commentedon Apr 17, 2025
Further development on this feature would be greatly appreciated. We are developing a quite huge monolith and want to seperate different scopes in different schemas, but it would be a pain without the capability to migrate.
This not only makes the db more structured, but we could also give other services read-only access to some of the schemas without the need to specify every single table the role should have access to.
FGoessler commentedon Jun 18, 2025
@kokokenada thank you for your feedback! We are considering this for our work to move the multiSchema preview feature to GA.
Regarding Prisma Postgres: I am talking with our team working on this area whether we can make this work for native Prisma connections. In the meantime you can try to use direct TCP connections to Prisma Postgres. Based on my testing they support the
schema=...query param as expected.FGoessler commentedon Jun 19, 2025
Hi @ineshbose 👋
Could you please elaborate what your use case is to use multiple schemas with SQLite? 🤔
ineshbose commentedon Jun 24, 2025
Yes, of course. I'm mostly looking at keeping separate schemas for different tables in my database, similar to a
publicschema in postgres and then, say,authschema with user-account tables. I do have a setup in my project where we use postgres in prod and sqlite in dev with the help ofprismaSchemaFolderas outlined in this discussion, but the only issue now is that I'm unable to make use of@@schemain local dev environment for sqlite. Again, multi-schema workaround aside, I'm looking to keep schemas separate in my database between public and auth for now.FGoessler commentedon Jul 29, 2025
With today's release of Prisma 6.13.0 we are moving multi schema support to general availability for Postgres and SQL Server. 🎉
We are hence closing this issue as completed.
Please note that multiple databases schemas for SQLite and MySQL are not supported and not on our current roadmap. Both databases work fundamentally different regarding schemas and demand for multi schema on them has been very low.
If you encounter issues with the multi schema feature please open fresh issues.