I'm learning Prisma ORM from video tutorials and official docs. They are explain and write All model code in one file called schema.prisma
. It's ok but, when application grow it became messy. So, how should I separate my Model definition into separate file?
Starting from Prisma 5.15 this can be done without any external tools, please see the following blog post.
Briefly, all you need to do is:
In your schema.prisma file - make sure you have this feature enabled as follows:
generator client { provider = "prisma-client-js" previewFeatures = ["prismaSchemaFolder"] }
Create a dir named schema under your prisma directory
Move your schema.prisma file into that directory. You should now be able to create more .prisma files in there and define your models. It all gets hooked up automatically, no need to import anything.