Config and Prisma Schema Mismatch (plugin/organization) #658

Closed
opened 2026-03-13 07:59:12 -05:00 by GiteaMirror · 6 comments
Owner

Originally created by @D3OXY on GitHub (Feb 11, 2025).

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 places, including relation definitions.
  • No references to Organization should remain in the Prisma schema.

What version of Better Auth are you using?

1.1.16

Provide environment information

- OS: Windows 11

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

When configuring the organization plugin in Better Auth to use workspace instead, the Prisma schema still refers to Organization in some places (mainly in relation definitions). The expected behavior is that all occurrences of Organization should be renamed to Workspace.

Image

Image

Originally created by @D3OXY on GitHub (Feb 11, 2025). ### 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 places, including relation definitions. - No references to `Organization` should remain in the Prisma schema. ### What version of Better Auth are you using? 1.1.16 ### Provide environment information ```bash - OS: Windows 11 ``` ### 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 When configuring the `organization` plugin in Better Auth to use `workspace` instead, the Prisma schema still refers to `Organization` in some places (mainly in relation definitions). The expected behavior is that all occurrences of `Organization` should be renamed to `Workspace`. ![Image](https://github.com/user-attachments/assets/f4dc2d53-579a-4293-85b8-075935dbd898) ![Image](https://github.com/user-attachments/assets/8359aa2e-ee6b-497b-9a68-708a84b61d53)
GiteaMirror added the bug label 2026-03-13 07:59:12 -05:00
Author
Owner

@lord007tn commented on GitHub (Feb 21, 2025):

error persists in 1.1.19

@lord007tn commented on GitHub (Feb 21, 2025): error persists in 1.1.19
Author
Owner

@Sliov commented on GitHub (Apr 15, 2025):

Same issue here with drizzle, mapping fields don't seem to work within the organization plugin

@Sliov commented on GitHub (Apr 15, 2025): Same issue here with drizzle, mapping fields don't seem to work within the organization plugin
Author
Owner

@ricardolmsilva commented on GitHub (Jun 13, 2025):

Problem persists 1.2.8

@ricardolmsilva commented on GitHub (Jun 13, 2025): Problem persists 1.2.8
Author
Owner

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

Hi, @D3OXY. I'm Dosu, and I'm helping the better-auth team manage their backlog and am marking this issue as stale.

Issue Summary:

  • You reported that the Better Auth organization plugin does not fully apply a custom model name ("workspace") in the Prisma schema, still referencing the default "Organization" model.
  • This causes inconsistencies starting from version 1.1.16.
  • Other users confirmed the issue persists in versions 1.1.19 and 1.2.8.
  • Additional complications with field mapping were noted when using the organization plugin alongside Drizzle.
  • The issue remains unresolved across multiple versions.

Next Steps:

  • Please let me know if this issue is still relevant with the latest version of better-auth by commenting below to keep the discussion open.
  • If I do not hear back within 7 days, I will automatically close this issue.

Thank you for your understanding and contribution!

@dosubot[bot] commented on GitHub (Sep 12, 2025): Hi, @D3OXY. I'm [Dosu](https://dosu.dev), and I'm helping the better-auth team manage their backlog and am marking this issue as stale. **Issue Summary:** - You reported that the Better Auth organization plugin does not fully apply a custom model name ("workspace") in the Prisma schema, still referencing the default "Organization" model. - This causes inconsistencies starting from version 1.1.16. - Other users confirmed the issue persists in versions 1.1.19 and 1.2.8. - Additional complications with field mapping were noted when using the organization plugin alongside Drizzle. - The issue remains unresolved across multiple versions. **Next Steps:** - Please let me know if this issue is still relevant with the latest version of better-auth by commenting below to keep the discussion open. - If I do not hear back within 7 days, I will automatically close this issue. Thank you for your understanding and contribution!
Author
Owner

@bsl-aura commented on GitHub (Sep 15, 2025):

Stil persists

@bsl-aura commented on GitHub (Sep 15, 2025): Stil persists
Author
Owner

@ping-maxwell commented on GitHub (Sep 30, 2025):

This should be resolved, if it still persist please open a new issue for up-to-date info on your setup

@ping-maxwell commented on GitHub (Sep 30, 2025): This should be resolved, if it still persist please open a new issue for up-to-date info on your setup
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#658