#creation of new user failed and exited an error in vercel logs for my project

11 messages · Page 1 of 1 (latest)

hazy flame
#

In the creation of new users I made use of better auth for authentication and the creation of a new user in my nextjs project which I integrated with prisma as my ORM with supabase as my database............. this arrangement however performs the creation of the new user in development however after deploying to vercel and performing the same authentication of new users it throws this error which indicates that the new user cannot be created and i don't seem to know why it doesn't work in deployment where i have added the environemt variables required by prisma like the DATABASE_URL and the DIRECT_URL needed by prisma to connect to my supabase database and this connnection worked fine

The error from vercel logs upon creation of new users:

[Better Auth] ERROR
Invalid prisma.user.findFirst() invocation:

The table public.User does not exist in the current database.

Invalid prisma.user.findFirst() invocation:

The table public.User does not exist in the current database.
at $n.handleRequestError (node_modules/@prisma/client/runtime/library.js:121:7315)
at $n.handleAndLogRequestError (node_modules/@prisma/client/runtime/library.js:121:6623)
at $n.request (node_modules/@prisma/client/runtime/library.js:121:6307)
at async l (node_modules/@prisma/client/runtime/library.js:130:9633)
at async Object.findOne (.next/server/app/api/auth/[...all]/route.js:2689:39615)
at async Object.findUserByEmail (.next/server/app/api/auth/[...all]/route.js:85:21632)
at async .next/server/app/api/auth/[...all]/route.js:85:1052
at async i (.next/server/app/api/auth/[...all]/route.js:1:66010)
at async s.<computed> (.next/server/app/api/auth/[...all]/route.js:85:6930)
at async s (.next/server/app/api/auth/[...all]/route.js:1:70740)

@everyone

#

@everyone

dreamy lichen
#

Hi @hazy flame

Did you run npx prisma migrate deploy in your production environment? This applies your Prisma migrations to create necessary tables.

hazy flame
#

i added this line "vercel-build": "prisma generate && prisma migrate deploy && next build" to the scripts in my package.json which has prisma migrate deploy in it and should be executed when vercel builds the application or should i have vercel run it separately?

dreamy lichen
#

That's the correct procedure. You don't need to run it separately. Can you inspect your supabase database that the tables are created correctly?

hazy flame
#

okay let me give it a try

hazy flame
#

I implemeted it and i reset my database and ran prisma db push to reinitialze the schema and migrations present as i made them in my prisma schema............. but stiill anyime a new user is being created i still receive the same error 500 in my vercel logs meaning that the new user is not created and it didn't work but it works in development and i honestly don't know the cause of this issue or how i can resolve it

this is the log i am still receiving after making those changes you said i should try

[Better Auth] ERROR
Invalid prisma.user.findFirst() invocation:

The table public.User does not exist in the current database.

Invalid prisma.user.findFirst() invocation:

The table public.User does not exist in the current database.
at $n.handleRequestError (node_modules/@prisma/client/runtime/library.js:121:7315)
at $n.handleAndLogRequestError (node_modules/@prisma/client/runtime/library.js:121:6623)
at $n.request (node_modules/@prisma/client/runtime/library.js:121:6307)
at async l (node_modules/@prisma/client/runtime/library.js:130:9633)
at async Object.findOne (.next/server/app/api/auth/[...all]/route.js:2689:39615)
at async Object.findUserByEmail (.next/server/app/api/auth/[...all]/route.js:85:21632)
at async .next/server/app/api/auth/[...all]/route.js:85:1052
at async i (.next/server/app/api/auth/[...all]/route.js:1:66010)
at async s.<computed> (.next/server/app/api/auth/[...all]/route.js:85:6930)
at async s (.next/server/app/api/auth/[...all]/route.js:1:70740)

@everyone @dreamy lichen

dreamy lichen
#

Hi @hazy flame

I missed this tag. Is this issue resolved or you still need help?

hazy flame
#

@dreamy lichen yes it worked finally i found out that the cause of the error had to be from the database for some reasons not being in sync to my database so i decided to delete all my migrations, reset the database and then i ran npx prisma migrate dev --name init which i used to initialize the whole project and then i ran npx prisma migrate dev to ensure that the migration worked well afterwards i ran npx prisma generate and then it all worked

#

thanks a lot.......