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

generator client {
  provider      = "prisma-client-js"
  binaryTargets = ["native", "rhel-openssl-1.0.x", "darwin"]
}

generator prismaClassGenerator {
  provider               = "node -r ts-node/register/transpile-only src/index.ts"
  output                 = "../src/_gen/prisma-class"
  dryRun                 = "false"
  separateRelationFields = "false"
}

enum ProductType {
  A
  B
  C
}

enum ProductAnotherType {
  AA
  BB
  CC
}

model Product {
  id            Int                @id
  title         String             @db.VarChar(255)
  desc          String             @default("abc") @db.VarChar(1024)
  images        Json               @db.Json
  isShown       Boolean?           @default(false)
  stock         Int?               @default(0)
  type          ProductType
  anotherType   ProductAnotherType @default(AA)
  averageRating Float?
  categoryId    Int
  companyId     Int
  category      Category           @relation(fields: [categoryId], references: [id])
  company       Company            @relation(fields: [companyId], references: [id])
  createdAt     DateTime           @default(now()) @db.Timestamp(6)
  updatedAt     DateTime           @updatedAt @db.Timestamp(6)
}

model Category {
  id       Int       @id
  products Product[]
}

model Company {
  id                      Int       @id
  name                    String
  totalIncome             BigInt    @default(100)
  lat                     Decimal
  lng                     Decimal
  by                      Bytes
  products                Product[]
  tags                    String[]
  tagsWithEmptyDefault    String[]  @default([])
  tagsWithDefault         String[]  @default(["a", "b"])
  numTags                 Int[]
  numTagsWithEmptyDefault Int[]     @default([])
  numTagsWithDefault      Int[]     @default([1, 2])
}
