Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

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.

Did you ran prisma generate to generate Prisma client after making changes on Prisma schema ? prisma migrate dev will also generate Prisma client along with migration. – Pasindu Dilshan Sep 22, 2021 at 5:38 In addition to what @PasinduDilshan mentioned (which is a likely cause of the problem), is this issue only with the Support model? Do all other models work as expected? – Tasin Ishmam Sep 22, 2021 at 8:53 @TasinIshmam yes every other models worked properly. This error has been only for Support model because I had already pushed news models to the production server and I never had this type of error. This could be because I just started to use prisma migrate deploy with this Support model. And this is exactly what @Pasindudilshan said with the prisma migrate dev which also generates Prisma client and why I never had this error before. – Peter Sep 23, 2021 at 8:07 Yes, prisma migrate deploy does not generate the client, so you have to run prisma generate as was mentioned. Just to clarify, you have been able to solve the problem now? – Tasin Ishmam Sep 23, 2021 at 9:33 If you are using Typescript, open up the Command Palette (Ctrl Shift P), and typing "Restart Typescript Server", and press enter. Would help as well, without the need to restart VSCode – monkfromearth Dec 7, 2022 at 7:09 I remember that I had the same problem and fixed it with that, but now it doesn't work anymore on any device after restarts and it won't build, so not a vscode issue this time. What now?? – france1 Mar 10 at 14:36

My issue was that the prisma client references the model names but as camelCase, whereas they're defined in the schema using PascalCase. This threw me because most of my model names are single words so where I'd defined a model name like User in the schema and added @@map("user") to the definition, I had the impression that when I did something like await prisma.user.delete({ ... the model/ table name user was lowercase as a result of the @@map declaration, but it turns out it isn't, rather prisma takes the model name and makes the first letter lowercase, and hence why for my model name OTP (with @@map("otp)) I have to use it like prisma.oTP.delete({ ...

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.