[GH-ISSUE #8967] Config and Prisma Schema Mismatch (plugin/organization) #28570

Open
opened 2026-04-17 20:01:03 -05:00 by GiteaMirror · 1 comment
Owner

Originally created by @husseinraoouf on GitHub (Apr 5, 2026).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/8967

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

Steps to Reproduce:

  1. Configure the Better Auth organization plugin to use workspace as the model name.
  2. Run the npx @better-auth/cli generate command.

Current vs. Expected behavior

Expected Behavior:

  • The model name workspace should be applied consistently across all generated Prisma schema output, including the model name itself and relation definitions.
  • No references to Organization should remain in the Prisma schema.

What version of Better Auth are you using?

1.5.6

Provide environment information

- OS: macOS

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

Backend, Client

Auth config (if applicable)

import { betterAuth } from "better-auth";
import { prismaAdapter } from "better-auth/adapters/prisma";
import { db } from "@/server/db";
import { admin as adminPlugin } from "better-auth/plugins";
import { organization } from "better-auth/plugins";
import { ac, admin, member, owner } from "@/lib/auth/permissions";

export const auth = betterAuth({
    database: prismaAdapter(db, {
        provider: "postgresql",
    }),
    plugins: [
        adminPlugin({
            defaultRole: "user",
            adminRole: ["admin"],
            defaultBanReason: "No reason",
            defaultBanExpiresIn: 60 * 60 * 24, // 1 day
        }),
        organization({
            ac: ac,
            roles: {
                member,
                admin,
                owner,
            },
            allowUserToCreateOrganization: async (_user) => {
                // TODO: Implement subscription based workspace creation
                return true;
            },
            async sendInvitationEmail(_data) {
                // TODO: Implement invitation email sending (data.id is the invitation id)
                console.log("Not implemented");
            },
            schema: {
                organization: {
                    modelName: "workspace",
                },
                member: {
                    modelName: "workspaceMember",
                    fields: {
                        organizationId: "workspaceId",
                    },
                },
                invitation: {
                    modelName: "workspaceInvitation",
                    fields: {
                        organizationId: "workspaceId",
                    },
                },
            },
        }),
    ],
    socialProviders: {
        github: {
            clientId: process.env.GITHUB_CLIENT_ID!,
            clientSecret: process.env.GITHUB_CLIENT_SECRET!,
        },
    },
});

Additional context

This appears to be the same issue as #1414, but it is still reproducible for us on the latest Better Auth version (1.5.6).

When configuring the organization plugin in Better Auth to use workspace instead, the generated Prisma schema still refers to Organization throughout the output, including the model name itself and relation definitions. The expected behavior is that all occurrences of Organization should be renamed to Workspace.

Originally created by @husseinraoouf on GitHub (Apr 5, 2026). Original GitHub issue: https://github.com/better-auth/better-auth/issues/8967 ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce #### **Steps to Reproduce:** 1. Configure the Better Auth `organization` plugin to use `workspace` as the model name. 2. Run the `npx @better-auth/cli generate` command. ### Current vs. Expected behavior #### **Expected Behavior:** - The model name `workspace` should be applied consistently across all generated Prisma schema output, including the model name itself and relation definitions. - No references to `Organization` should remain in the Prisma schema. ### What version of Better Auth are you using? 1.5.6 ### Provide environment information ```bash - OS: macOS ``` ### Which area(s) are affected? (Select all that apply) Backend, Client ### Auth config (if applicable) ```typescript import { betterAuth } from "better-auth"; import { prismaAdapter } from "better-auth/adapters/prisma"; import { db } from "@/server/db"; import { admin as adminPlugin } from "better-auth/plugins"; import { organization } from "better-auth/plugins"; import { ac, admin, member, owner } from "@/lib/auth/permissions"; export const auth = betterAuth({ database: prismaAdapter(db, { provider: "postgresql", }), plugins: [ adminPlugin({ defaultRole: "user", adminRole: ["admin"], defaultBanReason: "No reason", defaultBanExpiresIn: 60 * 60 * 24, // 1 day }), organization({ ac: ac, roles: { member, admin, owner, }, allowUserToCreateOrganization: async (_user) => { // TODO: Implement subscription based workspace creation return true; }, async sendInvitationEmail(_data) { // TODO: Implement invitation email sending (data.id is the invitation id) console.log("Not implemented"); }, schema: { organization: { modelName: "workspace", }, member: { modelName: "workspaceMember", fields: { organizationId: "workspaceId", }, }, invitation: { modelName: "workspaceInvitation", fields: { organizationId: "workspaceId", }, }, }, }), ], socialProviders: { github: { clientId: process.env.GITHUB_CLIENT_ID!, clientSecret: process.env.GITHUB_CLIENT_SECRET!, }, }, }); ``` ### Additional context This appears to be the same issue as #1414, but it is still reproducible for us on the latest Better Auth version (`1.5.6`). When configuring the `organization` plugin in Better Auth to use `workspace` instead, the generated Prisma schema still refers to `Organization` throughout the output, including the model name itself and relation definitions. The expected behavior is that all occurrences of `Organization` should be renamed to `Workspace`.
GiteaMirror added the bug label 2026-04-17 20:01:03 -05:00
Author
Owner

@jaydeep-pipaliya commented on GitHub (Apr 10, 2026):

Hi! I'd like to work on this.

The issue is that npx @better-auth/cli generate produces Prisma schema relations referencing the default Organization model name instead of the user-configured custom name (e.g., Workspace). I'll trace the CLI schema generator to find where the custom model name mapping is dropped.

Could you please assign this to me?

<!-- gh-comment-id:4222943860 --> @jaydeep-pipaliya commented on GitHub (Apr 10, 2026): Hi! I'd like to work on this. The issue is that `npx @better-auth/cli generate` produces Prisma schema relations referencing the default `Organization` model name instead of the user-configured custom name (e.g., `Workspace`). I'll trace the CLI schema generator to find where the custom model name mapping is dropped. Could you please assign this to 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#28570