I’m working on ReactJS project with NextJS Framework and Prisma to manage connection and queries to the DB.
On my local project the Support model is found and when I use it in my API and build my project it’s ok.
But when I push my project on production server (Plesk), the build shows me this typescript error because it doesn’t find the Support model:
./src/pages/api/support/index.ts:27:26
Type error: Property 'support' does not exist on type 'PrismaClient<PrismaClientOptions, never, RejectOnNotFound | RejectPerOperation | undefined>'.
The path ./src/pages/api/support/index.ts
is where I want to use the Support model
My prisma.schema
:
datasource db {
provider = "mysql"
url = env("DATABASE_CONNECTION")
}
generator client {
provider = "prisma-client-js"
}
model User {
id Int @id @unique @default(autoincrement())
gender String?
firstName String
lastName String
email String @unique
phone String
birthday DateTime?
income Float?
pincode Int?
points Float?
token String @db.Text
ipAddress String
kyc Kyc[]
createdAt DateTime @default(now())
updatedAt DateTime?
isValidated Boolean @default(false)
roleId Int
role Role @relation(fields: [roleId], references: [id])
Alerts Alerts[]
Support Support[]
}
model Kyc {
id Int @id @unique @default(autoincrement())
name String
validated Boolean @default(false)
path String
createdAt DateTime @default(now())
updatedAt DateTime? @updatedAt
user User @relation(fields: [userId], references: [id])
userId Int
}
model Alerts {
id Int @id @unique @default(autoincrement())
type TYPE @default(NOBLOCKED)
message String @db.Text
transferId Int @unique
fromUserId Int
read Boolean @default(false)
createdAt DateTime @default(now())
user User @relation(fields: [fromUserId], references: [id])
}
model Role {
id Int @id @unique @default(autoincrement())
name String
User User[]
}
model Support {
id Int @id @unique @default(autoincrement())
subject String
message String @db.Text
createdAt DateTime @default(now())
userId Int
user User @relation(fields: [userId], references: [id])
}
enum TYPE {
BLOCKED
NOBLOCKED
}
I don’t know if I need to use prisma migrate dev
or prisma migrate deploy
each time I push the latest changes.
7
Answers
I tried prisma generate and prisma migrate dev but was still having the same error. I had to restart VSCode and everything is working fine now
In my case, I created a schema named
Post
, but I calledawait prisma.posts
. It should be calledawait prisma.posts
. Make sure you don’t make Typo. 😅I forgot to await
but should be:
Note! I’m only refer to the title of the question and not to the content. This error also can be raised also when you don’t working with the right node version like in situation when using nvm with old node version.
used
prisma generate
command but still, the schemas were marked as red. I had to restart my web storm IDE to get it fixed.I have restarted my Visual Studio code and it started working fine.
Restart your typescript server in VSCode
CTRL + SHIFT + P
then type:restart TS Server