Merging Existing Drizzle User Table with Better Auth Core Schema

Hi everyone, I’m working on integrating Better Auth into my project that already uses Drizzle ORM. I already ran my migrations and created my custom User table using Drizzle. My table (defined in schema.ts) includes columns like first_name, last_name, and email_address. Now, I’m trying to merge Better Auth’s core schema with my existing user table to have a unified user record. I would like to map Better Auth’s expected fields to my existing columns. For example, I've configured it to map emailVerified to my custom column email_verified instead of the default. My Questions: 1. Is this the recommended way to merge my existing user table with the core schema Better Auth requires? 2. Am I correct in assuming that I don’t need to explicitly list fields like emailVerified in additionalFields because Better Auth will generate them via migrations? 3. Are there any improvements or gotchas when mapping fields (e.g., combining first_name and last_name into a full name)? Any help or suggestions would be appreciated!
No description
No description
2 Replies
bekacru
bekacru3mo ago
1. yes 2. no you should explicitly define them 3. you can define both first name and last name as additional fields instead and use name as a full name definition instead. And make sure the mapping is similar to your schema keys in drizzle instead of the actual field in the db. Meaning
filedName: varchar("filed_name") // on auth config should be specefied as `fieldName` instead of `field_name` since better auth works in the orm layer in this case
filedName: varchar("filed_name") // on auth config should be specefied as `fieldName` instead of `field_name` since better auth works in the orm layer in this case
wild-silent
wild-silentOP3mo ago
@bekacru Thanks

Did you find this page helpful?