Does prisma support the ability to fetch data from multiple schemas from within a single database?
Asked
Active
Viewed 6,082 times
7
-
Hey! What do you mean exactly with this? With "schema", do you mean a "GraphQL schema" or a "[PostgreSQL schema](https://www.postgresql.org/docs/9.1/ddl-schemas.html)" or something else? – nburk Jan 26 '21 at 08:59
-
the latter one. @nburk – Muhammad Rehan Qadri Jan 26 '21 at 16:11
-
Did you find a solution for using multiple Postgres schema's with Prisma? This is one thing that is preventing me from using it. – Jonathan Jan 01 '22 at 16:21
-
1@Jonathan, we'd to drop Prisma just because of this limitations. I haven't checked Prisma after it, whether they support it now or not. – Muhammad Rehan Qadri Jan 12 '22 at 07:23
-
What did you end up using? – Jonathan Jan 13 '22 at 04:08
-
GraphQL with simple Sequelize in one product (that required multi-tenancy) and GraphQL and Dynamo DB using AWS SAM at another. @Jonathan – Muhammad Rehan Qadri Jan 14 '22 at 11:45
2 Answers
6
That is not yet possible. Here's a GitHub issue that had been created you can use to monitor the feature's status and give your feedback too.
Could you also share your use case too? Your feedback will be highly appreciated as we relay it back to the team.

Alex Ruheni
- 989
- 5
- 6
0
Prisma multiSchema
is now supported as a preview feature.
See here https://www.prisma.io/docs/guides/database/multi-schema
It was introduced in version 4.3.0 https://github.com/prisma/prisma/issues/1122#issuecomment-1231773471
As the docs say you would add the preview feature...
generator client {
provider = "prisma-client-js"
previewFeatures = ["multiSchema"]
}
Then in your datasource you note the schemas...
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
schemas = ["schema1", "schema2"]
}
And finally in each model you add the @@schema
attribute...
model User {
id Int @id
orders Order[]
profile Profile?
@@schema("schema1")
}
model Order {
id Int @id
user User @relation(fields: [id], references: [id])
user_id Int
@@schema("schema2")
}

shmuels
- 1,039
- 1
- 9
- 22