🆘 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:
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:
2. Adding schema mappings in the organization plugin config:
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!

12 Replies
@admin plz help. it's bit urgent
did you pass in the schema to better auth?
show your auth config
yes i passed. let me share the code
Hi @Blank
here you can see the auth config
https://gist.github.com/jacksonkasi1/7caada448f40579e541edee4de0076b4
Gist
🆘 Field mapping issue with organization plugin: 'userId does not...
🆘 Field mapping issue with organization plugin: 'userId does not exist in schema for model member - packages\better-auth\README.md
have you run the migrations?
the code looks fine
Should I use Drizzle migration or BetterAuth CLI migration?
If it's BetterAuth CLI, does it support Turborepo? Because both the database and BetterAuth are managed as separate packages
drizzle one
Hi @Blank
Earlier, I used
drizzle-kit push
.
Just now, I created a new database and this time used drizzle-kit migrate
:
Then, I created an account and tried to create an organization, but I got the same error:
Any suggestions?Try changing your schema to have the variable with how BA wants it, but within the drizzle field definiton, keep it the way you had it, here's an example:
Hi @Ping, thanks for your suggestion. Why doesn't BetterAuth support custom column names? https://www.better-auth.com/docs/concepts/database#custom-table-names
Database | Better Auth
Learn how to use a database with Better Auth.
I think it's just for drizzle adapter.
Thanks for the suggestion @Ping . I'd really like to maintain snake_case throughout my codebase for consistency, not just in the database columns.
Is there any way to make Better Auth work with snake_case variable names too? The documentation mentions support for custom field names, so it seems like this should be possible.
If I have to use camelCase variables as you suggested, can I at least use something like Zod or a type layer to maintain snake_case in my application code while just having the camelCase in the schema definition?