🆘 Field mapping issue with organization plugin: 'userId does not exist in schema for model member

Hello Better Auth community 👋

I'm having an issue with the organization plugin and field mapping. When trying to create an organization, I get this error:

[BetterAuthError: The field "userId" does not exist in the schema for the model "member". Please update your schema.]


My setup:
  • Using Better Auth with Drizzle adapter
  • Database fields use snake_case (user_id, organization_id, etc.)
  • Organization plugin configured with proper field mappings
I've tried:
  1. Adding field mappings at the root level in my `betterAuth()` config:```jsmember: {modelName: "member",fields: { userId: "user_id", organizationId: "organization_id", teamId: "team_id"}}```
  2. Adding schema mappings in the organization plugin config:```jsorganization({// Other options...schema: { member: { fields: { userId: "user_id", organizationId: "organization_id", teamId: "team_id" } }}})```
But I still get the same error. What's the proper way to map camelCase field names to snake_case database columns for the organization plugin?

Any help would be appreciated! Thanks!
image.png
image.png
Was this page helpful?