Feature Request: Support Prisma Multi-file Schemas (prismaSchemaFolder) in CLI Generate #2669

Closed
opened 2026-03-13 10:12:09 -05:00 by GiteaMirror · 4 comments
Owner

Originally created by @cvpv on GitHub (Jan 8, 2026).

Is this suited for github?

  • Yes, this is suited for github

I'm frustrated when using Prisma's Multi-file Schema feature (available since Prisma v5.15.0 via prismaSchemaFolder preview feature, and widely adopted).

prisma doc : multi-file-prisma-schema

In my project, I split my Prisma schema into multiple files (e.g., prisma/models/user.prisma, prisma/models/post.prisma) to keep things organized.

However, when I run npx @better-auth/cli generate to update my schema with Better Auth fields (like adding banReason from a custom plugin), the CLI fails or behaves incorrectly.

I checked the source code in packages/cli/src/generators/prisma.ts and found that generatePrismaSchema hardcodes the path to ./prisma/schema.prisma (line 20) and only logic to read/write a single file. It does not support scanning a directory or updating a specific file where the User model is actually defined.

Describe the solution you'd like

I would like the Better Auth CLI to support multi-file Prisma schemas.

Specifically:

  1. Detection: The CLI should be able to detect if prisma/schema.prisma enables previewFeatures = ["prismaSchemaFolder"] or if the user is using the multi-file structure.
  2. Smart Update: Instead of assuming everything is in schema.prisma, it should find which .prisma file contains the User, Session, etc., models and update that specific file.
  3. Configurable Path: If automatic detection is too complex, allow passing a directory path or a glob pattern to the CLI to tell it where to look for models.

Describe alternatives you've considered

Currently, the only alternative is to manually copy-paste the schema changes generated by Better Auth into my split files, or force myself to use a monolithic schema.prisma file, which degrades the developer experience in large projects.

Additional context

Reference to Prisma Multi-file Schema docs: https://www.prisma.io/docs/orm/prisma-schema/overview/location#multi-file-prisma-schema

The issue seems to stem from packages/cli/src/generators/prisma.ts:

// packages/cli/src/generators/prisma.ts
const filePath = file || "./prisma/schema.prisma";
// ...
schemaPrisma = await fs.readFile(path.join(process.cwd(), filePath), "utf-8");

This logic assumes a single-file source of truth.

No response

Originally created by @cvpv on GitHub (Jan 8, 2026). ### Is this suited for github? - [ ] Yes, this is suited for github ### Is your feature request related to a problem? Please describe. I'm frustrated when using Prisma's Multi-file Schema feature (available since Prisma v5.15.0 via `prismaSchemaFolder` preview feature, and widely adopted). [prisma doc : multi-file-prisma-schema](https://www.prisma.io/docs/orm/prisma-schema/overview/location#multi-file-prisma-schema) In my project, I split my Prisma schema into multiple files (e.g., `prisma/models/user.prisma`, `prisma/models/post.prisma`) to keep things organized. However, when I run `npx @better-auth/cli generate` to update my schema with Better Auth fields (like adding `banReason` from a custom plugin), the CLI fails or behaves incorrectly. I checked the source code in `packages/cli/src/generators/prisma.ts` and found that `generatePrismaSchema` hardcodes the path to `./prisma/schema.prisma` (line 20) and only logic to read/write a **single file**. It does not support scanning a directory or updating a specific file where the `User` model is actually defined. ### Describe the solution you'd like I would like the Better Auth CLI to support multi-file Prisma schemas. Specifically: 1. **Detection**: The CLI should be able to detect if `prisma/schema.prisma` enables `previewFeatures = ["prismaSchemaFolder"]` or if the user is using the multi-file structure. 2. **Smart Update**: Instead of assuming everything is in `schema.prisma`, it should find which `.prisma` file contains the `User`, `Session`, etc., models and update that specific file. 3. **Configurable Path**: If automatic detection is too complex, allow passing a directory path or a glob pattern to the CLI to tell it where to look for models. ### Describe alternatives you've considered Currently, the only alternative is to manually copy-paste the schema changes generated by Better Auth into my split files, or force myself to use a monolithic `schema.prisma` file, which degrades the developer experience in large projects. ### Additional context Reference to Prisma Multi-file Schema docs: https://www.prisma.io/docs/orm/prisma-schema/overview/location#multi-file-prisma-schema The issue seems to stem from `packages/cli/src/generators/prisma.ts`: ```typescript // packages/cli/src/generators/prisma.ts const filePath = file || "./prisma/schema.prisma"; // ... schemaPrisma = await fs.readFile(path.join(process.cwd(), filePath), "utf-8"); ``` This logic assumes a single-file source of truth. _No response_
GiteaMirror added the enhancement label 2026-03-13 10:12:09 -05:00
Author
Owner

@better-auth-agent[bot] commented on GitHub (Jan 8, 2026):

Thank you for your feature request regarding Better Auth CLI's support for Prisma’s multi-file schema. It appears that there is already an open issue on GitHub addressing similar concerns about the CLI's current handling of multi-file schemas, specifically highlighting the need for better detection and updates for split schema files when using the prismaSchemaFolder feature.

The feature requests include:

  1. Detection of the use of previewFeatures for multi-file schemas.
  2. Smart updates to ensure changes are directed to the appropriate schema file rather than a default single file.
  3. A configurable path to specify where to look for schema files.

You might want to keep track of this ongoing conversation or contribute further insight on that issue. Your input could help shape the implementation of this requested feature.

Would you like to discuss any other improvements or ideas you might have regarding Better Auth?

If you need more help, tag @better-auth-agent in a comment so I can respond.

DiagramDiscordGitHub

Diagram Join Star

@better-auth-agent[bot] commented on GitHub (Jan 8, 2026): Thank you for your feature request regarding Better Auth CLI's support for Prisma’s multi-file schema. It appears that there is already an open issue on GitHub addressing similar concerns about the CLI's current handling of multi-file schemas, specifically highlighting the need for better detection and updates for split schema files when using the `prismaSchemaFolder` feature. The feature requests include: 1. **Detection** of the use of `previewFeatures` for multi-file schemas. 2. **Smart updates** to ensure changes are directed to the appropriate schema file rather than a default single file. 3. A **configurable path** to specify where to look for schema files. You might want to keep track of this ongoing conversation or contribute further insight on that issue. Your input could help shape the implementation of this requested feature. Would you like to discuss any other improvements or ideas you might have regarding Better Auth? _If you need more help, tag @better-auth-agent in a comment so I can respond._ <!-- bot:webhook reply v1 --> [Diagram](https://repodiagrams.s3.eu-north-1.amazonaws.com/skyvern_ultra_detailed_interactive.html) • [Discord](https://discord.gg/fG2XXEuQX3) • [GitHub](https://github.com/Skyvern-AI/Skyvern) [![Diagram](https://img.shields.io/badge/Diagram-2b3137?style=flat-square)](https://repodiagrams.s3.eu-north-1.amazonaws.com/skyvern_ultra_detailed_interactive.html) [![Join](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&style=flat-square)](https://discord.gg/fG2XXEuQX3) [![Star](https://img.shields.io/badge/star-181717?logo=github&logoColor=white&style=flat-square)](https://github.com/Skyvern-AI/Skyvern)
Author
Owner

@cvpv commented on GitHub (Jan 8, 2026):

@better-auth-agent Where can I find that issue?

@cvpv commented on GitHub (Jan 8, 2026): @better-auth-agent Where can I find that issue?
Author
Owner

@better-auth-agent[bot] commented on GitHub (Jan 8, 2026):

It looks like you're interested in the feature request regarding better support for Prisma's multi-file schemas in the Better Auth CLI. The issue is currently open and discusses potential enhancements to allow the CLI to work with multiple schema files, specifically for better handling of Prisma's prismaSchemaFolder feature.

In brief, here are some key points from the discussions around this topic:

  1. The CLI currently defaults to a single schema file, which doesn't align with the multi-file approach many developers are adopting.
  2. Recommendations include adding logic to detect multi-file schemas or allowing users to specify a directory for their schemas directly.
  3. There have been related issues and feature requests highlighting similar concerns, aiming to improve the developer experience with multi-file schemas [1], [4].

If you're looking for more information on this, you might want to keep an eye on these open issues and feature requests for updates or upcoming changes.

Would you like to explore how these features could enhance your project workflow, or do you have other questions about Better Auth?

DiagramDiscordGitHub

Diagram Join Star

@better-auth-agent[bot] commented on GitHub (Jan 8, 2026): It looks like you're interested in the feature request regarding better support for Prisma's multi-file schemas in the Better Auth CLI. The issue is currently open and discusses potential enhancements to allow the CLI to work with multiple schema files, specifically for better handling of Prisma's `prismaSchemaFolder` feature. In brief, here are some key points from the discussions around this topic: 1. The CLI currently defaults to a single schema file, which doesn't align with the multi-file approach many developers are adopting. 2. Recommendations include adding logic to detect multi-file schemas or allowing users to specify a directory for their schemas directly. 3. There have been related issues and feature requests highlighting similar concerns, aiming to improve the developer experience with multi-file schemas [[1]](https://github.com/better-auth/better-auth/issues/7139), [[4]](https://github.com/better-auth/better-auth/pull/3216). If you're looking for more information on this, you might want to keep an eye on these open issues and feature requests for updates or upcoming changes. Would you like to explore how these features could enhance your project workflow, or do you have other questions about Better Auth? <!-- bot:webhook reply v1 --> [Diagram](https://repodiagrams.s3.eu-north-1.amazonaws.com/skyvern_ultra_detailed_interactive.html) • [Discord](https://discord.gg/fG2XXEuQX3) • [GitHub](https://github.com/Skyvern-AI/Skyvern) [![Diagram](https://img.shields.io/badge/Diagram-2b3137?style=flat-square)](https://repodiagrams.s3.eu-north-1.amazonaws.com/skyvern_ultra_detailed_interactive.html) [![Join](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&style=flat-square)](https://discord.gg/fG2XXEuQX3) [![Star](https://img.shields.io/badge/star-181717?logo=github&logoColor=white&style=flat-square)](https://github.com/Skyvern-AI/Skyvern)
Author
Owner

@bytaesu commented on GitHub (Jan 9, 2026):

Hi @cvpv,

Thanks for the report. This seems to be a duplicate of https://github.com/better-auth/better-auth/issues/7139, so I'll close this.

Feel free to reopen this or mention me 🙂

@bytaesu commented on GitHub (Jan 9, 2026): Hi @cvpv, Thanks for the report. This seems to be a duplicate of https://github.com/better-auth/better-auth/issues/7139, so I'll close this. Feel free to reopen this or mention me 🙂
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#2669