prismixer
Version:
Allow you to create multiple Prisma schema files
101 lines (79 loc) • 1.91 kB
Markdown
# `Prismixer`
This package allow you to create multiple Prisma schema files, supporting cross-file and model relations
> Learn more about Prisma: [prisma.io](https://prisma.io)
[](https://www.npmjs.com/package/prismixer)
[](https://www.npmjs.com/package/prismixer)
## Installation
1. Install Prismixer
```
yarn add --dev prismixer
```
2. Create a `prismixer.config.json` file in the root of your project.
```json
{
"input": ["base.prisma", "./src/modules/**/**.prisma"],
"output": "prisma/schema.prisma"
}
```
```
The order of your input files effects how overrides are considered
```
## Relation Example
## `base.prisma`
```prisma
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "mysql"
url = "mysql://..."
}
```
## `account.prisma`
```prisma
model Account {
id String (cuid())
email String
password String
@("accounts")
}
```
## `posts.prisma`
```prisma
model Post {
id String (cuid())
title String
content String
account_id String
account Account (fields: [account_id], references: [id])
@("posts")
}
model Account {
id String (cuid())
posts Post[]
}
```
## Native database field Example
## `base.prisma`
```prisma
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "mysql"
url = "mysql://..."
}
```
## `posts.prisma`
```prisma
# 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 (cuid())
title String
content String .LongText # Set field as long text type
}
```