Skip to content

Multiple Prisma connections and schemas #24247

Closed Answered by ludralph
rdrigos asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @rdrigos 👋

To work with multiple databases, you can create separate schema files for each database. In each schema file, you define the datasource with the respective database connection string. Here's an example of how you can set up your schema files:
For Database 1, create a schema file prisma/db-1/schema.prisma:

datasource db {
  provider = "sqlserver"
  url      = env("DATABASE_URL_DB_1")
}

generator client {
  provider        = "prisma-client-js"
  output          = "../../node_modules/@prisma-db-1/client"
}

For Database 2, create a schema file prisma/db-2/schema.prisma:

datasource db {
  provider = "sqlserver"
  url      = env("DATABASE_URL_DB_2")
}

generator client {
  provider

Replies: 1 comment 10 replies

Comment options

You must be logged in to vote
10 replies
@simibruda
Comment options

@rdrigos
Comment options

@simibruda
Comment options

@ludralph
Comment options

@simibruda
Comment options

Answer selected by rdrigos
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants