Renamed email field via auth config results in auth error
Using
better-auth@1.3.8-beta.3
with prisma adapter
I've renamed several columns via the auth config (to use snake case column names), and also changed the database column names (via prisma migration). But upon logging in there's a query error thrown which is attempting to use the custom field name email_address
instead of the prisma model name email
.
auth.ts
schema.prisma
Error after login:
web:dev: 2025-08-28T18:56:17.248Z ERROR [Better Auth]: Better auth was unable to query your database. web:dev: Error: Error [PrismaClientValidationError]: web:dev: Invalidprisma.user.findFirst()
invocation: web:dev: web:dev: { web:dev: where: { web:dev: email_address: "email@gmail.com", web:dev:~~~~~ web:dev: ? AND?: UserWhereInput | UserWhereInput[], web:dev: ? OR?: UserWhereInput[], web:dev: ? NOT?: UserWhereInput | UserWhereInput[], web:dev: ? id?: StringFilter | String, web:dev: ? name?: StringFilter | String, web:dev: ? email?: StringFilter | String, web:dev: ? emailVerified?: BoolFilter | Boolean, web:dev: ? image?: StringNullableFilter | String | Null, web:dev: ? createdAt?: DateTimeFilter | DateTime, web:dev: ? updatedAt?: DateTimeFilter | DateTime, web:dev: ? sessions?: SessionListRelationFilter, web:dev: ? accounts?: AccountListRelationFilter web:dev: }, web:dev: select: undefined web:dev: } web:dev: web:dev: Unknown argumentemail_address
. Available options are marked with ?. web:dev: at ignore-listed frames { web:dev: clientVersion: '6.15.0' web:dev: }
2 Replies
Why 😭
Why am i attempting to rename?
Hmm - now i understand the why. The
fields
customisation in auth config is just if you want to change the model properties, not the column names 🤦♂️ Reverting the auth config changes and just using the @map
in the schema.prisma
works as expected.