Prisma type issue

I'm having a difficult time figuring out why this error is occurring (pictured). I created a model within schema.prisma for the input ("address") to be pushed into.
model URLData {
id String @id @default(cuid())
address String
accounts Account[]
sessions Session[]
}
model URLData {
id String @id @default(cuid())
address String
accounts Account[]
sessions Session[]
}
I npx db pushed and generated. It then will prompt me npx prisma format, which adds this to the premade Account model:
URLData URLData? @relation(fields: [uRLDataId], references: [id])
uRLDataId String?
URLData URLData? @relation(fields: [uRLDataId], references: [id])
uRLDataId String?
Any help is appreciated.
Solution:
The schema looks fine for what the error is showing for, so it's not related to the schema (although you should evaluate it logically to confirm it's what you want) Use your Code Editor's LSP: type ctx.prisma. and see how the URLData is being shown in it...
Jump to solution
8 Replies
Grey
Grey2y ago
First off, did you push after the 2nd prompt n' fix or before Secondly, did you run prisma generate? if that doesn't work then: can you share all of the models in question here? as the Account and Session model need that @relation which I need to see to know if it is properly set or not
emzra
emzraOP2y ago
// 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"
previewFeatures = ["jsonProtocol"]
}

datasource db {
provider = "sqlite"
// NOTE: When using mysql or sqlserver, uncomment the @db.Text annotations in model Account below
// Further reading:
// https://next-auth.js.org/adapters/prisma#create-the-prisma-schema
// https://www.prisma.io/docs/reference/api-reference/prisma-schema-reference#string
url = env("DATABASE_URL")
}

model Example {
id String @id @default(cuid())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}

// Necessary for Next auth
model Account {
id String @id @default(cuid())
userId String
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?
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@unique([provider, providerAccountId])
}

model Session {
id String @id @default(cuid())
sessionToken String @unique
userId String
expires DateTime
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
}

model User {
id String @id @default(cuid())
name String?
email String? @unique
emailVerified DateTime?
image String?
accounts Account[]
sessions Session[]
}

model VerificationToken {
identifier String
token String @unique
expires DateTime

@@unique([identifier, token])
}

model URLData {
id String @id @default(cuid())
address String
}
// 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"
previewFeatures = ["jsonProtocol"]
}

datasource db {
provider = "sqlite"
// NOTE: When using mysql or sqlserver, uncomment the @db.Text annotations in model Account below
// Further reading:
// https://next-auth.js.org/adapters/prisma#create-the-prisma-schema
// https://www.prisma.io/docs/reference/api-reference/prisma-schema-reference#string
url = env("DATABASE_URL")
}

model Example {
id String @id @default(cuid())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}

// Necessary for Next auth
model Account {
id String @id @default(cuid())
userId String
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?
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@unique([provider, providerAccountId])
}

model Session {
id String @id @default(cuid())
sessionToken String @unique
userId String
expires DateTime
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
}

model User {
id String @id @default(cuid())
name String?
email String? @unique
emailVerified DateTime?
image String?
accounts Account[]
sessions Session[]
}

model VerificationToken {
identifier String
token String @unique
expires DateTime

@@unique([identifier, token])
}

model URLData {
id String @id @default(cuid())
address String
}
Yes, I did both
Grey
Grey2y ago
then
Solution
Grey
Grey2y ago
The schema looks fine for what the error is showing for, so it's not related to the schema (although you should evaluate it logically to confirm it's what you want) Use your Code Editor's LSP: type ctx.prisma. and see how the URLData is being shown in it
Grey
Grey2y ago
usually when we define models in prisma, the generated ones show in lowercase with ctx.prisma for example the User model is ctx.prisma.user not ctx.prisma.User
Grey
Grey2y ago
Even your error message is hinting to it
emzra
emzraOP2y ago
Okay, that seems to have fixed it.
emzra
emzraOP2y ago
Thanks for the help.
Want results from more Discord servers?
Add your server