Untitled

 avatar
unknown
plain_text
14 days ago
1.3 kB
3
Indexable
model Voucher {
  id              String           @id @default(uuid())
  code            String           @unique
  discountype     DiscountType
  discountValue   Decimal          @db.Decimal(10, 2)
  minSpend        Decimal?         @db.Decimal(10, 2)
  maxDiscount     Decimal?         @db.Decimal(10, 2)
  usageLimit      Int              @default(1)
  usedCount       Int              @default(0)
  appliesToAll    Boolean          @default(false)
  startDate       DateTime         @default(now())
  endDate         DateTime?
  createdAt       DateTime         @default(now())
  updatedAt       DateTime         @updatedAt
  voucherUsages   VoucherUsage[]
  voucherProducts VoucherProduct[]
}

model VoucherProduct {
  id        String  @id @default(uuid())
  voucher   Voucher @relation(fields: [voucherId], references: [id], onDelete: Cascade)
  voucherId String
  product   Product @relation(fields: [productId], references: [product_id])
  productId String
}

model VoucherUsage {
  id        String   @id @default(uuid())
  voucher   Voucher  @relation(fields: [voucherId], references: [id], onDelete: Cascade)
  voucherId String
  product   Product? @relation(fields: [productId], references: [product_id])
  productId String?
  orderId   String?
  createdAt DateTime @default(now())
}
Leave a Comment