paljs / prisma-tools

Prisma tools to help you generate CRUD system for GraphQL servers
https://paljs.com
MIT License
681 stars 55 forks source link

pal schema camel-case TypeError: Cannot read property 'replace' of undefined #229

Closed guhyeon closed 2 years ago

guhyeon commented 2 years ago

OS - window database - mariadb

  1. prisma pull => generated schema.prisma with snake_case
  2. pal schema camel-case

schema.zip

AhmedElywa commented 2 years ago

Would you please share your complete error message?

AhmedElywa commented 2 years ago

it's working very good

generator client {
  provider = "prisma-client-js"
}

generator typegraphql {
  provider = "typegraphql-prisma"
  output   = "../prisma/generated/type-graphql"
}

datasource db {
  provider = "mysql"
  url      = env("DATABASE_URL")
}

model category {
  id              Int       @id @default(autoincrement())
  categoryNm      String?   @map("category_nm") @db.VarChar(50)
  upperCategoryId Int?      @map("upper_category_id")
  groupId         Int?      @map("group_id")
  depth           Int?
  regId           Int?      @map("reg_id")
  regDt           DateTime? @map("reg_dt") @db.DateTime(0)
  modId           Int?      @map("mod_id")
  modDt           DateTime? @map("mod_dt") @db.DateTime(0)
}

model contract {
  id              Int       @id @default(autoincrement())
  contractNm      String?   @map("contract_nm") @db.VarChar(100)
  contractSection String?   @map("contract_section") @db.Char(3)
  description     String?   @db.Text
  delYn           String?   @default("N") @map("del_yn") @db.Char(1)
  regId           Int?      @map("reg_id")
  regDt           DateTime? @map("reg_dt") @db.DateTime(0)
  modId           Int?      @map("mod_id")
  modDt           DateTime? @map("mod_dt") @db.DateTime(0)
}

model investor {
  id                 Int       @id @default(autoincrement())
  name               String?   @db.VarChar(20)
  grade              String?   @db.VarChar(20)
  username           String?   @db.VarChar(50)
  sexdstn            String?   @db.Char(1)
  birthday           String?   @db.VarChar(10)
  email              String?   @db.VarChar(50)
  mbtlnum            String?   @db.VarChar(20)
  zipcode            String?   @db.VarChar(10)
  address            String?   @db.VarChar(200)
  detailaddress      String?   @db.VarChar(200)
  emailRecptnYn      String?   @map("email_recptn_yn") @db.Char(1)
  smsRecptnYn        String?   @map("sms_recptn_yn") @db.Char(1)
  subscribeDt        DateTime? @map("subscribe_dt") @db.DateTime(0)
  secessionDt        DateTime? @map("secession_dt") @db.DateTime(0)
  delYn              String?   @default("N") @map("del_yn") @db.Char(1)
  acnutno            String?   @db.VarChar(20)
  bankCd             String?   @map("bank_cd") @db.VarChar(5)
  bankNm             String?   @map("bank_nm") @db.VarChar(10)
  acnutnm            String?   @db.VarChar(20)
  bsnCharger         Int?      @map("bsn_charger")
  emailRecptnEstbsDt DateTime? @map("email_recptn_estbs_dt") @db.DateTime(0)
  smsRecptnEstbsDt   DateTime? @map("sms_recptn_estbs_dt") @db.DateTime(0)
  alarmYn            String?   @map("alarm_yn") @db.Char(1)
  remark             String?   @db.VarChar(2000)
  regId              Int?      @map("reg_id")
  regDt              DateTime? @map("reg_dt") @db.DateTime(0)
  modId              Int?      @map("mod_id")
  modDt              DateTime? @map("mod_dt") @db.DateTime(0)
}

model InvestorContract {
  investorId   Int       @map("investor_id")
  contractId   Int       @map("contract_id")
  shopId       Int       @map("shop_id")
  attachFileId Int       @map("attach_file_id")
  delYn        String?   @default("N") @map("del_yn") @db.Char(1)
  regId        Int?      @map("reg_id")
  regDt        DateTime? @map("reg_dt") @db.DateTime(0)
  modId        Int?      @map("mod_id")
  modDt        DateTime? @map("mod_dt") @db.DateTime(0)

  @@id([investorId, contractId, shopId, attachFileId])
  @@map("investor_contract")
}

model member {
  id                 Int       @id @default(autoincrement())
  name               String?   @db.VarChar(20)
  grade              String?   @db.VarChar(20)
  username           String?   @db.VarChar(50)
  sexdstn            String?   @db.Char(1)
  birthday           String?   @db.VarChar(10)
  email              String?   @db.VarChar(50)
  mbtlnum            String?   @db.VarChar(20)
  zipcode            String?   @db.VarChar(10)
  address            String?   @db.VarChar(200)
  detailaddress      String?   @db.VarChar(200)
  emailRecptnYn      String?   @map("email_recptn_yn") @db.Char(1)
  smsRecptnYn        String?   @map("sms_recptn_yn") @db.Char(1)
  subscribeDt        DateTime? @map("subscribe_dt") @db.DateTime(0)
  secessionDt        DateTime? @map("secession_dt") @db.DateTime(0)
  delYn              String?   @default("N") @map("del_yn") @db.Char(1)
  adultCertYn        String?   @default("N") @map("adult_cert_yn") @db.Char(1)
  emailRecptnEstbsDt DateTime? @map("email_recptn_estbs_dt") @db.DateTime(0)
  smsRecptnEstbsDt   DateTime? @map("sms_recptn_estbs_dt") @db.DateTime(0)
  alarmYn            String?   @map("alarm_yn") @db.Char(1)
  remark             String?   @db.VarChar(2000)
  regId              Int?      @map("reg_id")
  regDt              DateTime? @map("reg_dt") @db.DateTime(0)
  modId              Int?      @map("mod_id")
  modDt              DateTime? @map("mod_dt") @db.DateTime(0)
}

model prduct {
  id                 Int                @id @default(autoincrement())
  prductNm           String             @map("prduct_nm") @db.VarChar(200)
  barcode            String?            @db.Char(13)
  cateId1dp          Int?               @map("cate_id_1dp")
  cateId2dp          Int?               @map("cate_id_2dp")
  cateId3dp          Int?               @map("cate_id_3dp")
  sellStatus         String?            @map("sell_status") @db.Char(1)
  splpc              Int?
  vat                Int?
  sellingPrice       Int?               @map("selling_price")
  orgplce            String?            @db.VarChar(100)
  maker              String?            @db.VarChar(100)
  stndrd             String?            @db.VarChar(100)
  weight             String?            @db.VarChar(20)
  regId              Int?               @map("reg_id")
  regDt              DateTime?          @map("reg_dt") @db.DateTime(0)
  modId              Int?               @map("mod_id")
  modDt              DateTime?          @map("mod_dt") @db.DateTime(0)
  prduct_attach_file PrductAttachFile[]
  prduct_image       PrductImage[]
  prduct_thumbnail   PrductThumbnail[]
  stock              stock[]
}

model PrductAttachFile {
  no           Int       @id @default(autoincrement())
  prductId     Int?      @map("prduct_id")
  attachFileId Int?      @map("attach_file_id")
  regId        Int?      @map("reg_id")
  modId        Int?      @map("mod_id")
  regDt        DateTime? @map("reg_dt") @db.DateTime(0)
  modDt        DateTime? @map("mod_dt") @db.DateTime(0)
  prduct       prduct?   @relation(fields: [prductId], references: [id])

  @@index([prductId], name: "FK_PRDUCTATTACHFILE_PRDUCT_ID")
  @@map("prduct_attach_file")
}

model PrductImage {
  no           Int       @id @default(autoincrement())
  prductId     Int?      @map("prduct_id")
  attachFileId Int?      @map("attach_file_id")
  regId        Int?      @map("reg_id")
  modId        Int?      @map("mod_id")
  regDt        DateTime? @map("reg_dt") @db.DateTime(0)
  modDt        DateTime? @map("mod_dt") @db.DateTime(0)
  prduct       prduct?   @relation(fields: [prductId], references: [id])

  @@index([prductId], name: "FK_PRDUCTIMAGE_PRDUCT_ID")
  @@map("prduct_image")
}

model PrductThumbnail {
  no           Int       @id @default(autoincrement())
  prductId     Int?      @map("prduct_id")
  attachFileId Int?      @map("attach_file_id")
  useYn        String?   @map("use_yn") @db.Char(1)
  regId        Int?      @map("reg_id")
  modId        Int?      @map("mod_id")
  regDt        DateTime? @map("reg_dt") @db.DateTime(0)
  modDt        DateTime? @map("mod_dt") @db.DateTime(0)
  prduct       prduct?   @relation(fields: [prductId], references: [id])

  @@index([prductId], name: "FK_PRDUCTTHUMBNAIL_PRDUCT_ID")
  @@map("prduct_thumbnail")
}

model shop {
  id           Int       @id @default(autoincrement())
  shopNm       String?   @map("shop_nm") @db.VarChar(200)
  parentShopId Int?      @map("parent_shop_id")
  shopAddr1    String?   @map("shop_addr1") @db.VarChar(100)
  shopAddr2    String?   @map("shop_addr2") @db.VarChar(100)
  zipCode      String?   @map("zip_code") @db.VarChar(45)
  shopStatus   String    @map("shop_status") @db.Char(1)
  shopRegDt    DateTime? @map("shop_regDt") @db.DateTime(0)
  shopCloseDt  DateTime? @map("shop_close_dt") @db.DateTime(0)
  regId        Int?      @map("reg_id")
  regDt        DateTime  @default(now()) @map("reg_dt") @db.DateTime(0)
  modId        Int?      @map("mod_id")
  modDt        DateTime? @map("mod_dt") @db.DateTime(0)
  stock        stock[]
}

model stock {
  prductId Int       @map("prduct_id")
  shopId   Int       @map("shop_id")
  quantity Int?
  regId    Int?      @map("reg_id")
  regDt    DateTime  @default(now()) @map("reg_dt") @db.DateTime(0)
  modId    Int?      @map("mod_id")
  modDt    DateTime? @map("mod_dt") @db.DateTime(0)
  prduct   prduct    @relation(fields: [prductId], references: [id])
  shop     shop      @relation(fields: [shopId], references: [id])

  @@id([prductId, shopId])
  @@index([shopId], name: "FK_STOCK_SHOP_ID")
}

model board {
  id      BigInt  @id @default(autoincrement()) @db.UnsignedBigInt
  title   String? @db.Text
  content String? @db.Text
}
guhyeon commented 2 years ago

Sorry, I can't view that error anymore. I delete models in schema and prisma pull, and retry. it works. thanks @AhmedElywa