I had a problem with prisma schema and took 2 days to solve it. Basically i was not able to login with google auth. I get below error. I fix it via below issue on github and I just want to calobrate with solution.
model Category {
id String @id @default(cuid()) @map("_id")
slug String @unique
title String
img String?
Posts Post[]
}
model Post {
id String @id @default(cuid()) @map("_id")
createdAt DateTime @default(now())
slug String @unique
title String
desc String
img String?
views Int @default(0)
catSlug String
cat Category @relation(fields: [catSlug], references: [slug])
userEmail String
user User @relation(fields: [userEmail], references: [email])
comments Comment[]
}
model Comment {
id String @id @default(cuid()) @map("_id")
createdAt DateTime @default(now())
desc String
userEmail String
user User @relation(fields: [userEmail], references: [email])
postSlug String
post Post @relation(fields: [postSlug], references: [slug])
}
Unknown argument provider_providerAccountId. Did you mean providerId_providerAccountId? Available options are listed in green. PrismaClientValidationError:
Invalid prisma.account.findUnique() invocation:
{
where: {
provider_providerAccountId: {
providerAccountId: "secret",
provider: "google"
},
? id?: String,
? providerId_providerAccountId?: AccountProviderIdProviderAccountIdCompoundUniqueInput,
? AND?: AccountWhereInput | AccountWhereInput[],
? OR?: AccountWhereInput[],
? NOT?: AccountWhereInput | AccountWhereInput[],
? userId?: StringFilter | String,
? providerType?: StringFilter | String,
? providerId?: StringFilter | String,
? providerAccountId?: StringFilter | String,
? refreshToken?: StringNullableFilter | String | Null,
? accessToken?: StringNullableFilter | String | Null,
? accessTokenExpires?: DateTimeNullableFilter | DateTime | Null,
? createdAt?: DateTimeFilter | DateTime,
? updatedAt?: DateTimeFilter | DateTime,
? user?: UserRelationFilter | UserWhereInput
},
select: {
user: true
}
}
Unknown argument `provider_providerAccountId`. Did you mean `providerId_providerAccountId`? Available options are listed in green.
at yn (/Users/cansurer/Documents/dev-workspace/next-react-blog/node_modules/@prisma/client/runtime/library.js:116:5852)
at wn.handleRequestError (/Users/cansurer/Documents/dev-workspace/next-react-blog/node_modules/@prisma/client/runtime/library.js:123:6429)
at wn.handleAndLogRequestError (/Users/cansurer/Documents/dev-workspace/next-react-blog/node_modules/@prisma/client/runtime/library.js:123:6119)
at wn.request (/Users/cansurer/Documents/dev-workspace/next-react-blog/node_modules/@prisma/client/runtime/library.js:123:5839)
at async l (/Users/cansurer/Documents/dev-workspace/next-react-blog/node_modules/@prisma/client/runtime/library.js:128:9763)
at async getUserByAccount (webpack-internal:///(rsc)/./node_modules/@auth/prisma-adapter/index.js:220:29) {
name: 'GetUserByAccountError',
code: undefined
}
I had a problem with prisma schema and took 2 days to solve it. Basically i was not able to login with google auth. I get below error. I fix it via below issue on github and I just want to calobrate with solution.
https://github.com/nextauthjs/next-auth/issues/3815
please do not forget to execute below code after you change your schema.prisma file
npx prisma db push
file should be like below:
// This is your Prisma schema file, // learn more about it in the docs: https://pris.ly/d/prisma-schema
// This is your Prisma schema file, // learn more about it in the docs: https://pris.ly/d/prisma-schema
generator client { provider = "prisma-client-js" }
datasource db { provider = "mongodb" url = env("DATABASE_URL") }
model User { id String @id @default(uuid()) @map("_id") name String email String @unique emailVerified DateTime? @map("email_verified") image String? createdAt DateTime @default(now()) updatedAt DateTime @updatedAt accounts Account[] sessions Session[] Post Post[] Comment Comment[]
@@map("users") }
model Account { id String @id @default(cuid()) @map("_id") userId String @map("user_id") type String? provider String providerAccountId String @map("provider_account_id") token_type String? refresh_token String? access_token String? expires_at Int? scope String? id_token String? createdAt DateTime @default(now()) updatedAt DateTime @updatedAt user User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@unique([provider, providerAccountId]) @@map("accounts") }
model Session { id String @id @default(cuid()) @map("_id") userId String? @map("user_id") sessionToken String @unique @map("session_token") accessToken String? @map("access_token") expires DateTime user User? @relation(fields: [userId], references: [id], onDelete: Cascade) createdAt DateTime @default(now()) updatedAt DateTime @updatedAt
@@map("sessions") }
model VerificationRequest { id String @id @default(cuid()) @map("_id") identifier String token String @unique expires DateTime createdAt DateTime @default(now()) updatedAt DateTime @updatedAt
@@unique([identifier, token]) }
model Category { id String @id @default(cuid()) @map("_id") slug String @unique title String img String? Posts Post[] }
model Post { id String @id @default(cuid()) @map("_id") createdAt DateTime @default(now()) slug String @unique title String desc String img String? views Int @default(0) catSlug String cat Category @relation(fields: [catSlug], references: [slug]) userEmail String user User @relation(fields: [userEmail], references: [email]) comments Comment[] }
model Comment { id String @id @default(cuid()) @map("_id") createdAt DateTime @default(now()) desc String userEmail String user User @relation(fields: [userEmail], references: [email]) postSlug String post Post @relation(fields: [postSlug], references: [slug]) }
ERROR :
[next-auth][warn][NEXTAUTH_URL] https://next-auth.js.org/warnings#nextauth_url [next-auth][error][adapter_error_getUserByAccount] https://next-auth.js.org/errors#adapter_error_getuserbyaccount Invalid
prisma.account.findUnique()
invocation:{ where: { provider_providerAccountId: {
? id?: String, ? providerId_providerAccountId?: AccountProviderIdProviderAccountIdCompoundUniqueInput, ? AND?: AccountWhereInput | AccountWhereInput[], ? OR?: AccountWhereInput[], ? NOT?: AccountWhereInput | AccountWhereInput[], ? userId?: StringFilter | String, ? providerType?: StringFilter | String, ? providerId?: StringFilter | String, ? providerAccountId?: StringFilter | String, ? refreshToken?: StringNullableFilter | String | Null, ? accessToken?: StringNullableFilter | String | Null, ? accessTokenExpires?: DateTimeNullableFilter | DateTime | Null, ? createdAt?: DateTimeFilter | DateTime, ? updatedAt?: DateTimeFilter | DateTime, ? user?: UserRelationFilter | UserWhereInput }, select: { user: true } }
Unknown argument
provider_providerAccountId
. Did you meanproviderId_providerAccountId
? Available options are listed in green. PrismaClientValidationError: Invalidprisma.account.findUnique()
invocation:{ where: { provider_providerAccountId: {