#13472·next-auth

MySQL Prisma schema has an inconsistent Account relation

Author: KariMuhammadCreated Jul 25, 2026Updated Jul 25, 2026
Labelstriage

The MySQL schema in the Prisma adapter documentation defines an inconsistent relationship between User and Account:

prisma
model User {
  accounts Account[]
}

model Account {
  userId String @unique
  user   User?  @relation(fields: [userId], references: [id])
}

There are two issues:

  1. userId is required, but the corresponding user relation is marked as optional.
  2. userId @unique prevents multiple accounts from referencing the same user. This conflicts with accounts Account[] and prevents users from linking multiple providers.

The relationship should instead be:

prisma
model User {
  accounts Account[]
}

model Account {
  userId String
  user   User @relation(fields: [userId], references: [id])
}

The existing @@unique([provider, providerAccountId]) constraint should remain because it uniquely identifies each provider account.

Is there any context that might help us understand?

The PostgreSQL, SQLite, and MongoDB examples use a required, non-unique userId and a required User relation.

Aligning the MySQL example with them accurately models the intended one-to-many relationship: every account belongs to one user, while one user may link multiple provider accounts, such as GitHub and Google.

Does the docs page already exist? Please link to it.

https://authjs.dev/getting-started/adapters/prisma#schema