Is there any way to atomize prisma Models, to not have too much code in the schema.prisma

Viewed 70

I want to know if is there some way to keep each prisma Model in a single file and then export each Model to the schema.prisma file

export model User {
    id                  Int      @id @unique @default(autoincrement())
    name                String   @db.VarChar(255)
    last_name           String   @db.VarChar(255)
    dateOf_birth        DateTime @db.Date()
}

and then

import {User} from 'User.prisma'

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

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

model User

so I can keep each model or table in individual file.

1 Answers

It's not possible natively to split the schema.prisma file into multiple files.

You could use the Aurora tool to split the schema files.

Related