#Multi Schema files not being detected in ElysiaJS

5 messages · Page 1 of 1 (latest)

solemn flame
#

I have a setup in ElysiaJS where my schema files are inside a directory called models, this has worked all along until Prisma 7, now my data models from other schema files are not being detected in schema.prisma when I generate.

Below is just an example

model User {
id   String
name   String
company   Company   // <= comes from a schema in another file
}```
deep orchidBOT
#

You opted for speed from this bot. Let's conjure up an answer right now!

deep orchidBOT
# deep orchid You opted for speed from this bot. Let's conjure up an answer right now!

This is almost always a schema location / config issue with the new multi-file setup, not with ElysiaJS itself.

From the docs and related issues, for multi-file schemas to work in Prisma 7 you must:

  1. Point Prisma to the folder, not a single file

If your structure is:

prisma/
  schema.prisma      // has datasource + generator
  models/
    user.prisma
    company.prisma

your config must point to the prisma folder (or whatever folder contains schema.prisma), not to schema.prisma itself. [Schema location]

For example, using prisma.config.ts in your project root:

import path from 'node:path'
import type { PrismaConfig } from 'prisma'

export default {
  schema: path.join('prisma'),
} satisfies PrismaConfig

Or in package.json:

{
  "prisma": {
    "schema": "./prisma"
  }
}

Or via CLI:

npx prisma generate --schema ./prisma
  1. Ensure datasource is in a file in that folder

schema.prisma (or another file in that folder) must contain the datasource block; Prisma then recursively loads all .prisma files under that folder. [Schema location]

  1. Place migrations next to the datasource file

If you’re using migrations, the migrations directory must sit next to the file that has the datasource:

prisma/
  migrations/
  schema.prisma
  models/
    user.prisma
    company.prisma

[Schema location]

  1. Common pitfall from issues

If you only point to ./prisma/models (or to schema.prisma directly), Prisma will not see the other files correctly and relations like company Company won’t resolve. You must give the folder that contains the main schema file. [[Multi-file invalid](<https://githu

deep orchidBOT
deep orchidBOT