Skip to content

[Question] It possible to create a multiple schema files? #466

@Prashant4900

Description

@Prashant4900

I'm currently working on a Dart backend project where I need to create multiple tables approx 15 or more but the problem is that when I generate my schema which is just 2 tables it already generates 4500+ lines of code with the file size (100kb) so I'm worried about what happen if I create more and more tables?

Also, it keeps storing every single model in the same files even though there is a high chance there are some models which different from each other and have no relation between them.

// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema

// Looking for ways to speed up your queries, or scale easily with your serverless or edge functions?
// Try Prisma Accelerate: https://pris.ly/cli/accelerate-init

generator client {
  provider = "dart run orm"
  output   = "../lib/gen/orm/"
}

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

model Users {
    id Int @id @default(autoincrement())
    firstName String
    lastName String
    email String
    password String

    isActive Boolean
    isSuperAdmin Boolean

    createdAt DateTime @default(now())
    updatedAt DateTime

    @@unique([email])

    @@map("users")
}

model Admins {
    id Int @id @default(autoincrement())
    firstName String
    lastName String
    email String
    password String

    isActive Boolean
    isSuperAdmin Boolean

    createdAt DateTime @default(now())
    updatedAt DateTime

    @@unique([email])

    @@map("admins")
}

*Describe the solution you'd like
Is it possible to split or in a different directory and create a different file for every schema?

For example: if I have 2 modules in my application admin and users I can able to define 2 different schema files admin.prisma and user.prisma in their respective modules and all the files will generate in their respective modules only while maintaining one single database connection.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions