Prisma monorepo schema generation in existing project #1690

Closed
opened 2026-03-13 08:56:42 -05:00 by GiteaMirror · 2 comments
Owner

Originally created by @mrspartak on GitHub (Aug 12, 2025).

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

  • Create pnpm monorepositor
  • Have prisma in a separate package with prisma client being exported
  • Import client to auth.ts and use command npx @better-auth/cli@latest generate

Current vs. Expected behavior

Current behavior:
Creates prisma folder with schema.prisma file in it. Can be fixed by providing path to prisma package, but will still produce datasource and client descriptions, that might already exist in project

Expected behavior:
Creates schema in prisma package folder properly, respecting if prismaSchemaFolder is used and if other schemas already exists.

What version of Better Auth are you using?

1.3.5

System info

System:
    OS: macOS 13.4.1
    CPU: (10) arm64 Apple M1 Max
    Memory: 152.09 MB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Browsers:
    Chrome: 139.0.7258.67
    Safari: 16.5.1

Which area(s) are affected? (Select all that apply)

Backend

Auth config (if applicable)

import { betterAuth } from "better-auth"
export const auth = betterAuth({
    database: prismaAdapter(prisma, {
      provider: "postgresql",
    }),
  })

Additional context

It can be fixed manually, but then with any changes to auth config it will require manual fixes again.

Originally created by @mrspartak on GitHub (Aug 12, 2025). ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce * Create pnpm monorepositor * Have prisma in a separate package with prisma client being exported * Import client to auth.ts and use command npx @better-auth/cli@latest generate ### Current vs. Expected behavior Current behavior: Creates prisma folder with schema.prisma file in it. Can be fixed by providing path to prisma package, but will still produce datasource and client descriptions, that might already exist in project Expected behavior: Creates schema in prisma package folder properly, respecting if prismaSchemaFolder is used and if other schemas already exists. ### What version of Better Auth are you using? 1.3.5 ### System info ```bash System: OS: macOS 13.4.1 CPU: (10) arm64 Apple M1 Max Memory: 152.09 MB / 32.00 GB Shell: 5.9 - /bin/zsh Browsers: Chrome: 139.0.7258.67 Safari: 16.5.1 ``` ### Which area(s) are affected? (Select all that apply) Backend ### Auth config (if applicable) ```typescript import { betterAuth } from "better-auth" export const auth = betterAuth({ database: prismaAdapter(prisma, { provider: "postgresql", }), }) ``` ### Additional context It can be fixed manually, but then with any changes to auth config it will require manual fixes again.
GiteaMirror added the adapter label 2026-03-13 08:56:42 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Aug 12, 2025):

Better Auth CLI's schema generation defaults to creating the Prisma schema at ./prisma/schema.prisma, but you can control the output location using the --output flag. For a pnpm monorepo with Prisma in a separate package, run the CLI from your monorepo root and specify the schema path in your Prisma package, for example:

npx @better-auth/cli@latest generate --output ./packages/prisma/schema.prisma

There isn't a dedicated prismaSchemaFolder config; the output path is set via the CLI flag. If the schema file already exists, the CLI will only overwrite it if the generated content has changed, and will prompt for confirmation unless you use --yes to skip prompts (sourcesource). This helps avoid unnecessary overwrites, but you’ll need to re-run the command and specify the output path whenever your auth config changes.

If you want to automate this, consider scripting the CLI command as part of your build or deployment process. Prisma schema migration is not supported by Better Auth CLI (source).

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Chat with Dosu Join Discord Share on X

@dosubot[bot] commented on GitHub (Aug 12, 2025): <!-- Answer --> Better Auth CLI's schema generation defaults to creating the Prisma schema at `./prisma/schema.prisma`, but you can control the output location using the `--output` flag. For a pnpm monorepo with Prisma in a separate package, run the CLI from your monorepo root and specify the schema path in your Prisma package, for example: ```bash npx @better-auth/cli@latest generate --output ./packages/prisma/schema.prisma ``` There isn't a dedicated `prismaSchemaFolder` config; the output path is set via the CLI flag. If the schema file already exists, the CLI will only overwrite it if the generated content has changed, and will prompt for confirmation unless you use `--yes` to skip prompts ([source](https://github.com/better-auth/better-auth/blob/0d16d8e02c52d97725d5781eb1420ef95fc629c1/packages/cli/src/commands/generate.ts), [source](https://github.com/better-auth/better-auth/pull/3826)). This helps avoid unnecessary overwrites, but you’ll need to re-run the command and specify the output path whenever your auth config changes. If you want to automate this, consider scripting the CLI command as part of your build or deployment process. Prisma schema migration is not supported by Better Auth CLI ([source](https://github.com/better-auth/better-auth/pull/3876)). <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/e276f87e-5006-4d31-80d4-301ddbdad73a?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/e276f87e-5006-4d31-80d4-301ddbdad73a?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/e276f87e-5006-4d31-80d4-301ddbdad73a?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/e276f87e-5006-4d31-80d4-301ddbdad73a?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/e276f87e-5006-4d31-80d4-301ddbdad73a?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/e276f87e-5006-4d31-80d4-301ddbdad73a?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/e276f87e-5006-4d31-80d4-301ddbdad73a?feedback_type=other)</sup>&nbsp;&nbsp;[![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/cdda13d9-dd27-4d31-b09a-5d8bec92de21/ask?utm_source=github)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/better-auth/better-auth/issues/3956)
Author
Owner

@Kinfe123 commented on GitHub (Aug 13, 2025):

This should fix your issue. if not please consider tagging me for reopening the issue.

@Kinfe123 commented on GitHub (Aug 13, 2025): This should fix your issue. if not please consider tagging me for reopening the issue.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#1690