Next.js Discord

Discord Forum

[SOLVED]NextAuth with drizzle orm error: getUserByAccounT

Answered
Spot-billed Duck posted this in #help-forum
Open in Discord
Avatar
Spot-billed DuckOP
So this is the error:

https://pastebin.com/wt7dw3ZW
(or [next-auth][error][adapter_error_getUserByAccount]
https://next-auth.js.org/errors#adapter_error_getuserbyaccount relation "account" does not exist {
message: 'relation "account" does not exist',
....}

My schema.ts:
https://pastebin.com/Eu31NGnm

and my nextauth config: https://pastebin.com/AD8E4UEU
Answered by Spot-billed Duck
I just removed the prefix, now it works 🙂
View full answer

17 Replies

Avatar
Spot-billed DuckOP
posted as txt:
Image
schema as txt:
Image
and nextauth :
Image
related to #JWT_TOKEN_ERROR NextAuth with @Capelin and @Dunker
Avatar
Dunker
you are not exporting your accounts, sessions and verificationTokens tables
// schema.ts

-const accounts = pgTable(
+export const accounts = pgTable(
-const sessions = pgTable(
+export const sessions = pgTable(
-const verificationTokens = pgTable(
+export const verificationTokens = pgTable(
remove drizzle folder, and run that package.json commands to generate, push db and run dev server
Avatar
Spot-billed DuckOP
okay i'll try it, btw it's a postgre error no ?
and I get this schéma from official doc
Avatar
Spot-billed DuckOP
I did it, same error
Avatar
Spot-billed DuckOP
I found the error:
With t3 stack, tables are composed like that:
{projetname}_table
but nextauth is searching in 'table'
so myprojet_account != account
Avatar
Dunker
so, what you think
Avatar
Spot-billed DuckOP
I just removed the prefix, now it works 🙂
Answer
Avatar
Dunker
awesome for real
now you can mark this as solved and remove it