This package allow you to create multiple Prisma schema files, supporting cross-file and model relations
Learn more about Prisma: prisma.io
- Install Prismixer
yarn add --dev prismixer
- Create a
prismixer.config.json
file in the root of your project.
{
"input": ["base.prisma", "./src/modules/**/**.prisma"],
"output": "prisma/schema.prisma"
}
The order of your input files effects how overrides are considered
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "mysql"
url = "mysql://..."
}
model Account {
id String @id @default(cuid())
email String
password String
@@map("accounts")
}
model Post {
id String @id @default(cuid())
title String
content String
account_id String
account Account @relation(fields: [account_id], references: [id])
@@map("posts")
}
model Account {
id String @id @default(cuid())
posts Post[]
}
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "mysql"
url = "mysql://..."
}
# You've to repeat the data source connector to allow you to use native database types
datasource db {
provider = "mysql"
url = "mysql://..."
}
model Post {
id String @id @default(cuid())
title String
content String @db.LongText # Set field as long text type
}