question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support for two or more databases with Prisma2

See original GitHub issue

Problem

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:closed
  • Created 3 years ago
  • Reactions:7
  • Comments:8 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
pantharshit00commented, Nov 2, 2020

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.

1reaction
pantharshit00commented, Aug 31, 2020

I am unable to reproduce this. I am able to use two different prisma client which points to two different databases in the code.

image

Since this issue is a bit old, please try again with the latest version of prisma.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found