Skip to content

lehcosta/prismixer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Prismixer

This package allow you to create multiple Prisma schema files, supporting cross-file and model relations

Learn more about Prisma: prisma.io

Downloads Downloads

Installation

  1. Install Prismixer
yarn add --dev prismixer
  1. 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

Relation Example

base.prisma

generator client {
  provider = "prisma-client-js"
}

datasource db {
  provider = "mysql"
  url      = "mysql://..."
}

account.prisma

model Account {
  id       String @id @default(cuid())
  email    String
  password String

  @@map("accounts")
}

posts.prisma

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[]
}

Native database field Example

base.prisma

generator client {
  provider = "prisma-client-js"
}

datasource db {
  provider = "mysql"
  url      = "mysql://..."
}

posts.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 @id @default(cuid())
  title String
  content String @db.LongText # Set field as long text type
}

About

Create multiple Prisma schema files

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published