next.jsprismaprisma-graphqlprisma2

"Property does not exist" when I want to use model added in Prisma.schema


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.


Solution

  • 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