How to import a schema.prisma file inside another?

Viewed 920

One of my schema.prisma's file is wrote like this:

generator client {
  provider = "prisma-client-js"
  output   = "./generated/own_database"
}

datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

model Employee {
  ...
}

And I have another one, which is like this:

generator client {
    provider = "prisma-client-js"
    output   = "./generated/another_database"
}

datasource db {
    provider = "postgresql"
    url      = env("DATABASE_URL_2")
}

model Costs {
    cod_center_cost Int      @id
    description String?  @db.VarChar(100)
    status           Boolean?
    classification Int?
}

...

I have a model that needs to have a relation to another model, but how can I refer an another file's model?

1 Answers

Splitting Prisma's schema file is not officially possible yet.

However there are some community provided solutions like Aurora which provides you functionality to split prisma schemas and import them.

Here's the Official GitHub Issue where splitting schema file is being tracked by Prisma Team.

Related