Production NitroJS auth methods not working with Prisma #297

Closed
opened 2026-03-13 07:41:10 -05:00 by GiteaMirror · 1 comment
Owner

Originally created by @BayBreezy on GitHub (Nov 28, 2024).

Describe the bug
After building my project and running it in production mode, I keep getting the error below:

Invalid prisma.verification.create() invocation:

The table main.verification does not exist in the current database.

[Better Auth]  ERROR   If you are seeing this error, it is likely that you need to run the migrations for the database or you need to update your database schema. If you recently updated the package, make sure to run the migrations.

AND

Better Auth
Invalid prisma.user.findFirst() invocation:

The table main.user does not exist in the current database.

[Better Auth]  ERROR   If you are seeing this error, it is likely that you need to run the migrations for the database or you need to update your database schema. If you recently updated the package, make sure to run the migrations.

I tried performing the actions in the error

  • run the generate command: npx @better-auth/cli generate --config ./server/utils/auth.ts
  • run the generate for prisma: npx prisma generate
  • sync prisma: npx prisma db push

The issue is that this error does not happen during development. only after I run the build command and run it in production mode.

Expected behavior
I expect the auth endpoints to behave the same way in production as they do in dev mode

Screenshots
N/A

Desktop (please complete the following information):

  • OS: MacBook Pro
  • Chip: Apple M3 Pro
  • Browser: Arc
  • Version: 15.1.1

Smartphone (please complete the following information):
N/A

Additional context

Everything works fine during dev. The production version is where the issue is

Originally created by @BayBreezy on GitHub (Nov 28, 2024). **Describe the bug** After building my project and running it in production mode, I keep getting the error below: ```sh Invalid prisma.verification.create() invocation: The table main.verification does not exist in the current database. [Better Auth] ERROR If you are seeing this error, it is likely that you need to run the migrations for the database or you need to update your database schema. If you recently updated the package, make sure to run the migrations. ``` AND ```sh Better Auth Invalid prisma.user.findFirst() invocation: The table main.user does not exist in the current database. [Better Auth] ERROR If you are seeing this error, it is likely that you need to run the migrations for the database or you need to update your database schema. If you recently updated the package, make sure to run the migrations. ``` I tried performing the actions in the error - run the generate command: `npx @better-auth/cli generate --config ./server/utils/auth.ts` - run the generate for prisma: `npx prisma generate` - sync prisma: `npx prisma db push` The issue is that this error does not happen during development. only after I run the build command and run it in production mode. **Expected behavior** I expect the auth endpoints to behave the same way in production as they do in dev mode **Screenshots** N/A **Desktop (please complete the following information):** - OS: MacBook Pro - Chip: Apple M3 Pro - Browser: Arc - Version: 15.1.1 **Smartphone (please complete the following information):** N/A **Additional context** Everything works fine during dev. The production version is where the issue is
Author
Owner

@BayBreezy commented on GitHub (Nov 28, 2024):

So after a little more digging. I realised that the issue is with the sqlite type DB.

After I changed to mysql, the production build worked.

@BayBreezy commented on GitHub (Nov 28, 2024): So after a little more digging. I realised that the issue is with the `sqlite` type DB. After I changed to `mysql`, the production build worked.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#297