Argument `token` is missing.

Hey, has anyone managet to get better-auth working with Prisma? i'm migrating from Authjs (next auth) to better-auth and i used the npx @better-auth/cli generate as well to create the schema and everything but i keep getting this error, even though database is completely synced and prisma client is generated:
2025-02-03T17:37:38.779Z ERROR [Better Auth]:
Invalid `db[getModelName(model)].create()` invocation in
C:\TSProjects\metal-vault\.next\server\chunks\node_modules_better-auth_dist_d8816d._.js:2667:62

2664 if (!db[getModelName(model)]) {
2665 throw new __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$better$2d$auth$2f$dist$2f$chunk$2d$UNWCXKMP$2e$js__$5b$app$2d$route$5d$__$28$ecmascript$29$__["BetterAuthError"](`Model ${model} does not exist in the database. If you haven't generated the Prisma client, you need to run 'npx prisma generate'`);
2666 }
→ 2667 const result = await db[getModelName(model)].create({
data: {
id: "zaQ7MgVxGF3Tjt6j4s3N3RVxccavdpG0",
identifier: "gNXa4OG7LYTggzzvjqGAzh-2XG2axCFG",
value: "{\"callbackURL\":\"/\",\"codeVerifier\":\"nYca5-cBhdZBc-JhYybXGiSifmMpR7Dd67s4gHQ7JN7XfLSH8LNz2KU-F98czk0PBLcpG3ahXekkx0Jq-MI9JM-_epnoX5rbB0FxaeeaIedeur7p-XiekEYmgTSEztnE\",\"expiresAt\":1738604858735}",
expiresAt: new Date("2025-02-03T17:47:38.735Z"),
createdAt: new Date("2025-02-03T17:37:38.735Z"),
updatedAt: new Date("2025-02-03T17:37:38.735Z"),
+ token: String
},
select: undefined
})

Argument `token` is missing.
2025-02-03T17:37:38.779Z ERROR [Better Auth]:
Invalid `db[getModelName(model)].create()` invocation in
C:\TSProjects\metal-vault\.next\server\chunks\node_modules_better-auth_dist_d8816d._.js:2667:62

2664 if (!db[getModelName(model)]) {
2665 throw new __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f$better$2d$auth$2f$dist$2f$chunk$2d$UNWCXKMP$2e$js__$5b$app$2d$route$5d$__$28$ecmascript$29$__["BetterAuthError"](`Model ${model} does not exist in the database. If you haven't generated the Prisma client, you need to run 'npx prisma generate'`);
2666 }
→ 2667 const result = await db[getModelName(model)].create({
data: {
id: "zaQ7MgVxGF3Tjt6j4s3N3RVxccavdpG0",
identifier: "gNXa4OG7LYTggzzvjqGAzh-2XG2axCFG",
value: "{\"callbackURL\":\"/\",\"codeVerifier\":\"nYca5-cBhdZBc-JhYybXGiSifmMpR7Dd67s4gHQ7JN7XfLSH8LNz2KU-F98czk0PBLcpG3ahXekkx0Jq-MI9JM-_epnoX5rbB0FxaeeaIedeur7p-XiekEYmgTSEztnE\",\"expiresAt\":1738604858735}",
expiresAt: new Date("2025-02-03T17:47:38.735Z"),
createdAt: new Date("2025-02-03T17:37:38.735Z"),
updatedAt: new Date("2025-02-03T17:37:38.735Z"),
+ token: String
},
select: undefined
})

Argument `token` is missing.
4 Replies
bekacru
bekacru5w ago
you have token field in your verification table that's non nullable. you should remove it.
King Alastor
King AlastorOP5w ago
remove the token field or make it optional? i would have assumed the npx @better-auth/cli generate would already create the exact schema it needs to work
bekacru
bekacru5w ago
the cli doesn't generate that field unless you have added it as additonal field
King Alastor
King AlastorOP5w ago
okay, i created a separate clean project and ran the cli tool there to get the schema it needs (this was attempt #2 this way) and now i got the schema it needed and it works. Wish the website had the schema it needs just there to copy/paste so i could know exactly what it needs rather than hoping the cli tool worked. I used the cli tool in my main project as well so i got some messed up schemas

Did you find this page helpful?