Support for two or more databases with Prisma2
See original GitHub issueProblem
I have different PostgreSQL databases. But with Prisma2, I can apparently only use one database per app.
Solution
Support more then one database (maybe with separate Prima Clients?).
Additional context
I try to generate separate Prisma Clients with separate schema files: file db1-schema.prisma:
generator client {
provider = "prisma-client-js"
output = "../components/database/db1"
}
file db2-schema.prisma:
generator client {
provider = "prisma-client-js"
output = "../components/database/db2"
}
generate schemas:
npx prisma introspect --schema=./prisma/db1-schema.prisma
npx prisma introspect --schema=./prisma/db2-schema.prisma
geneate separate prisma clients:
npx prisma generate --schema=./prisma/db1-schema.prisma
npx prisma generate --schema=./prisma/db2-schema.prisma
But unfortunately I only get error messages when using it. Can that even work?
Issue Analytics
- State:
- Created 3 years ago
- Reactions:7
- Comments:8 (7 by maintainers)
Top Results From Across the Web
How to use Prisma with multiple database schemas
How to use Prisma with multiple database schemas. Multiple database schema support is currently available with the PostgreSQL and CockroachDB connectors.
Read more >I want to use multiple database in prisma orm - Stack Overflow
Create two different schema. prisma in separate folders and initialise PrismaClient for each schema. prisma that will point to the specific ...
Read more >How to connect Multiple Databases using Prisma in Nest JS
You can use multiple databases with Prisma by creating different schema files and generating separate Prisma clients for each database. References: github link ......
Read more >An introduction to Prisma 2 - LogRocket Blog
Currently, it supports MySQL, SQLite, PostgreSQL, SQL Server, and MongoDB. Prisma 2 consists of three major tools:.
Read more >Prisma | NestJS - A progressive Node.js framework
In this section, you'll create two new tables in your database using Prisma Migrate. Prisma Migrate generates SQL migration files for your declarative...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Well if you are using the Prisma plugin for nexus, I don’t think it can do that right now.
Please open an issue in the nexus repository underlying your use case if you want that feature.
I am unable to reproduce this. I am able to use two different prisma client which points to two different databases in the code.
Since this issue is a bit old, please try again with the latest version of prisma.