skip to Main Content

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


  1. 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

    Login or Signup to reply.
  2. In my case, I created a schema named Post, but I called await prisma.posts. It should be called await prisma.posts. Make sure you don’t make Typo. 😅

    Login or Signup to reply.
  3. I forgot to await

    const user = prisma.user.findUnique({ 
      where: {
        userId: authorUserId
      },
      select: {
        id: true
      }
    })
    

    but should be:

    const user = **await** prisma.user.findUnique({ 
      where: {
        userId: authorUserId
      },
      select: {
        id: true
      }
    })
    
    Login or Signup to reply.
  4. 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.

    Login or Signup to reply.
  5. used prisma generate command but still, the schemas were marked as red. I had to restart my web storm IDE to get it fixed.

    Login or Signup to reply.
  6. I have restarted my Visual Studio code and it started working fine.

    Login or Signup to reply.
  7. Restart your typescript server in VSCode
    CTRL + SHIFT + P then type: restart TS Server

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search