Migrating from nextauth/auth.js to better-auth

I'm currently in the process of migrating from auth.js to better-auth and have been following the guide here: https://www.better-auth.com/docs/guides/next-auth-migration-guide I've been able to map or create the new columns per the guide (within schema.prisma), but now when I try to log in with Google I get the following error:
# SERVER_ERROR: [Error [PrismaClientValidationError]:
(`Model ${model} does not exist in the database. If you haven't generated the Prisma client, you need to run 'npx prisma generate'`);
10172 }
10173 const whereClause = convertWhereClause(model, where);
→ 10174 return await db[model].update({
where: {
id: undefined,
? providerId_accountId?: AccountProviderIdAccountIdCompoundUniqueInput,
? AND?: AccountWhereInput | AccountWhereInput[],
? OR?: AccountWhereInput[],
? NOT?: AccountWhereInput | AccountWhereInput[],
? userId?: StringFilter | String,
? type?: StringNullableFilter | String | Null,
...
? user?: UserRelationFilter | UserWhereInput
},
data: {
accessToken: "",
idToken: "",
accessTokenExpiresAt: new Date("2025-06-09T02:44:21.400Z"),
scope: "https://www.googleapis.com/auth/userinfo.email,https://www.googleapis.com/auth/userinfo.profile,openid"
}
})

Argument `where` of type AccountWhereUniqueInput needs at least one of `providerId_accountId` arguments. Available options are marked with ?.] {
clientVersion: '5.22.0'
}
# SERVER_ERROR: [Error [PrismaClientValidationError]:
(`Model ${model} does not exist in the database. If you haven't generated the Prisma client, you need to run 'npx prisma generate'`);
10172 }
10173 const whereClause = convertWhereClause(model, where);
→ 10174 return await db[model].update({
where: {
id: undefined,
? providerId_accountId?: AccountProviderIdAccountIdCompoundUniqueInput,
? AND?: AccountWhereInput | AccountWhereInput[],
? OR?: AccountWhereInput[],
? NOT?: AccountWhereInput | AccountWhereInput[],
? userId?: StringFilter | String,
? type?: StringNullableFilter | String | Null,
...
? user?: UserRelationFilter | UserWhereInput
},
data: {
accessToken: "",
idToken: "",
accessTokenExpiresAt: new Date("2025-06-09T02:44:21.400Z"),
scope: "https://www.googleapis.com/auth/userinfo.email,https://www.googleapis.com/auth/userinfo.profile,openid"
}
})

Argument `where` of type AccountWhereUniqueInput needs at least one of `providerId_accountId` arguments. Available options are marked with ?.] {
clientVersion: '5.22.0'
}
From my testing, this seems to be because of @@id([providerId, accountId]) the error goes away when I replace this with a new id field/column in schema.prisma, but this would be a risky migration to run on a production database (it would break all existing references to the Account table). Are there any other solutions? Has anyone successfully migrated a production app from next-auth to better-auth?
Migrating from NextAuth.js to Better Auth | Better Auth
A step-by-step guide to transitioning from NextAuth.js to Better Auth.
1 Reply
FalconiZzare
FalconiZzare4mo ago
they are pretty much the same as far as I know. Also if you are migrating, why not first implement this on dev environment and if it's a success, deploy to prod? Also can I please see your updated prisma.schema?

Did you find this page helpful?