[GH-ISSUE #7139] Feat(cli): Support Prisma v7 multi-file schema #10744

Open
opened 2026-04-13 07:04:03 -05:00 by GiteaMirror · 2 comments
Owner

Originally created by @codingcyclist on GitHub (Jan 5, 2026).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/7139

Originally assigned to: @ping-maxwell on GitHub.

Is this suited for github?

  • Yes, this is suited for github

Is your feature request related to a problem? Please describe.

When using @better-auth/cli@latest generate --output prisma/schema/betterAuth.prisma with Prisma v7's multi-file schema setup, the CLI (v1.4.10) generates a complete standalone schema file that includes generator and datasource blocks:

generator client {
  provider = "prisma-client"
}

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

model User {
  // ...
}

In Prisma v7 with multi-file schemas (configured via prisma.config.ts with schema: "prisma/schema"), you should only have one generator and one datasource block across all .prisma files. The current output causes conflicts when the main schema.prisma already defines these blocks. This was partially addressed in PR #6459 (Prisma v7 compatibility) and discussed in issues #6277 and #3148, but the multi-file schema use case remains unsupported (even though there seems to be a pending PR from June: PR #3216 (feat(cli): multiple prisma schema file support))

Describe the solution you'd like

Add a --models-only flag (or similar) to the generate command that outputs only the model definitions without generator and datasource blocks: npx @better-auth/cli generate --output prisma/schema/betterAuth.prisma --models-only

Output would be:

// Better Auth models - generated by @better-auth/cli

model User {
  // ...
}

model Session {
  // ...
}
// etc.

Alternatively, auto-detect when --output points to a file inside a prisma/schema/ folder and omit the blocks automatically

Describe alternatives you've considered

  1. Manual editing - Remove generator and datasource blocks after each generation (tedious, error-prone)
  2. Post-generate script - Add a script to strip the blocks (workaround, not ideal)
  3. Single-file schema - Abandon multi-file setup (loses organizational benefits)

Additional context

Related issues: #6277, #3148
Related PRs: PR #6459 (Prisma v7 compatibility), PR #3216 (feat(cli): multiple prisma schema file support)
Prisma v7 multi-file schema docs: https://www.prisma.io/docs/orm/prisma-schema/overview/location
Using: @better-auth/cli@1.4.10, prisma@7.2.0

Originally created by @codingcyclist on GitHub (Jan 5, 2026). Original GitHub issue: https://github.com/better-auth/better-auth/issues/7139 Originally assigned to: @ping-maxwell on GitHub. ### Is this suited for github? - [x] Yes, this is suited for github ### Is your feature request related to a problem? Please describe. When using @better-auth/cli@latest generate --output prisma/schema/betterAuth.prisma with Prisma v7's multi-file schema setup, the CLI (v1.4.10) generates a complete standalone schema file that includes generator and datasource blocks: ```js generator client { provider = "prisma-client" } datasource db { provider = "postgresql" url = env("DATABASE_URL") } model User { // ... } ``` In Prisma v7 with multi-file schemas (configured via `prisma.config.ts` with schema: `"prisma/schema"`), you should only have one generator and one datasource block across all `.prisma` files. The current output causes conflicts when the main `schema.prisma` already defines these blocks. This was partially addressed in [PR #6459 (Prisma v7 compatibility)](https://github.com/better-auth/better-auth/pull/6459) and discussed in issues [#6277](https://github.com/better-auth/better-auth/issues/6277) and [#3148](https://github.com/better-auth/better-auth/issues/3148), but the multi-file schema use case remains unsupported (even though there seems to be a pending PR from June: [PR #3216 (feat(cli): multiple prisma schema file support)](https://github.com/better-auth/better-auth/pull/3216)) ### Describe the solution you'd like Add a `--models-only` flag (or similar) to the generate command that outputs only the model definitions without generator and datasource blocks: `npx @better-auth/cli generate --output prisma/schema/betterAuth.prisma --models-only` Output would be: ```js // Better Auth models - generated by @better-auth/cli model User { // ... } model Session { // ... } // etc. ``` Alternatively, auto-detect when `--output` points to a file inside a prisma/schema/ folder and omit the blocks automatically ### Describe alternatives you've considered 1. Manual editing - Remove generator and datasource blocks after each generation (tedious, error-prone) 2. Post-generate script - Add a script to strip the blocks (workaround, not ideal) 3. Single-file schema - Abandon multi-file setup (loses organizational benefits) ### Additional context Related issues: [#6277](https://github.com/better-auth/better-auth/issues/6277), [#3148](https://github.com/better-auth/better-auth/issues/3148) Related PRs: [PR #6459 (Prisma v7 compatibility)](https://github.com/better-auth/better-auth/pull/6459), [PR #3216 (feat(cli): multiple prisma schema file support)](https://github.com/better-auth/better-auth/pull/3216) Prisma v7 multi-file schema docs: https://www.prisma.io/docs/orm/prisma-schema/overview/location Using: @better-auth/cli@1.4.10, prisma@7.2.0
GiteaMirror added the devtoolsdatabase labels 2026-04-13 07:04:03 -05:00
Author
Owner

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

It sounds like you're looking for support regarding the integration of Prisma v7's multi-file schema with Better Auth. Currently, there is an open issue related to this topic [1], where users have expressed the need to support multiple Prisma schema files without the generator and datasource blocks being automatically included in the generated files.

A proposed solution includes the addition of a --models-only flag to the generate command, which would allow users to obtain model definitions only, avoiding conflicts with existing Prisma configurations.

If you have further questions or need assistance with this issue, I recommend tagging the Better Auth team members @bekacru or @ping__ to get a direct response. Is there anything else you’d like to know about Better Auth or Prisma?

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

DiagramDiscordGitHub

Diagram Join Star

<!-- gh-comment-id:3711494307 --> @better-auth-agent[bot] commented on GitHub (Jan 5, 2026): It sounds like you're looking for support regarding the integration of Prisma v7's multi-file schema with Better Auth. Currently, there is an open issue related to this topic [[1]](https://github.com/better-auth/better-auth/pull/3216), where users have expressed the need to support multiple Prisma schema files without the generator and datasource blocks being automatically included in the generated files. A proposed solution includes the addition of a `--models-only` flag to the generate command, which would allow users to obtain model definitions only, avoiding conflicts with existing Prisma configurations. If you have further questions or need assistance with this issue, I recommend tagging the Better Auth team members @bekacru or @ping__ to get a direct response. Is there anything else you’d like to know about Better Auth or Prisma? _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

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

@ping-maxwell could you handle this?

<!-- gh-comment-id:3718505096 --> @bytaesu commented on GitHub (Jan 7, 2026): @ping-maxwell could you handle this?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#10744