Next.js Discord

Discord Forum

NextAuth v5 Prisma error

Unanswered
Rhinelander posted this in #help-forum
Open in Discord
RhinelanderOP
Hey, does anyone understand why this code causes error
model User {
  id            String    @id @default(cuid())
  name          String?
  email         String    @unique
  emailVerified DateTime?
  image         String?
  accounts      Account[]
  sessions      Session[]

  role      UserRole? @default(GUEST)
  companies Company[]

  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt
}


but when i remove this it works just fine.
  role      UserRole? @default(GUEST)
  companies Company[]

The error is
[auth][details]: {}
[auth][error] AdapterError: Read more at https://errors.authjs.dev#adaptererror
[auth][cause]: PrismaClientKnownRequestError:
Invalid `prisma.session.delete()` invocation:


An operation failed because it depends on one or more records that were required but not found. Record to delete does not exist.


All I am trying to do is register user first to create company and assign a role to it and then using Resend I send login link to the emial address

0 Replies