Open mashwishi opened 3 months ago
is there updated for this?
I have finally solved the issue, So here's the steps I did.
Update packages @auth/prisma-adapter: 1.3.3 => 1.6.0 next-auth: 5.0.0-beta.5 => 5.0.0-beta.19
generator client {
provider = "prisma-client-js"
}
datasource db { provider = "mysql" url = env("DATABASE_URL") }
model Account { id Int @id @default(autoincrement()) userId Int type String provider String providerAccountId String refresh_token String? @db.Text access_token String? @db.Text expires_at Int? token_type String? scope String? id_token String? @db.Text session_state String? createdAt DateTime @default(now()) @db.DateTime(0) updatedAt DateTime @default(now()) @db.DateTime(0) user User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@unique([provider, providerAccountId]) }
enum UserRole { Admin Moderator User }
model User { id Int @id @default(autoincrement()) name String? email String? @unique emailVerified DateTime? image String? password String? role UserRole @default(User) accounts Account[] isTwoFactorEnabled Boolean @default(false) twoFactorConfirmation TwoFactorConfirmation? createdAt DateTime @default(now()) @db.DateTime(0) updatedAt DateTime @default(now()) @db.DateTime(0) }
model VerificationToken { id Int @id @default(autoincrement()) email String token String @unique expires DateTime
@@unique([email, token]) }
model ResetPasswordToken { id Int @id @default(autoincrement()) email String token String @unique expires DateTime
@@unique([email, token]) }
model TwoFactorToken { id Int @id @default(autoincrement()) email String token String @unique expires DateTime
@@unique([email, token]) }
model TwoFactorConfirmation { id Int @id @default(autoincrement()) userId Int @unique expires DateTime user User @relation(fields: [userId], references: [id], onDelete: Cascade) }
3. Run `npx prisma db push` to push my schema to database, but make sure your database is empty or new, no tables and other existing data because we are going to push this schema.
4. Run `npx prisma generate`, and after that run the project.
Adapter type
@auth/prisma-adapter
Environment
Reproduction URL
https://github.com/mashwishi/mash-nextauth
Describe the issue
I'm encountering an issue with NextAuth's Prisma adapter. When attempting to use prisma.account.findUnique() with a specific where clause, I'm getting an error indicating an invalid argument provider_providerAccountId. The error message suggests using providerId_providerAccountId instead.
Here's the error message I'm receiving:
And here's my Prisma schema:
I haven't modified the Prisma schema generated by npx prisma db pull, so I believe this might be an issue related to the adapter or how NextAuth interfaces with Prisma.
Thank you for your help in resolving this issue! Let me know if you need any more information.
How to reproduce
Attempt to use google signin, Here's my auth implementation:
Expected behavior
The expected behavior would be for the Prisma adapter to recognize and accept the provider_providerAccountId argument in the where clause of the prisma.account.findUnique() invocation without throwing an error. This means that the Prisma adapter should handle queries with this argument properly and not suggest a different argument (providerId_providerAccountId) in the error message.