8.4 무료쿠폰: 쿠폰 등록/재고/사용 처리/만료/1인 제한/로그 o
This commit is contained in:
@@ -220,6 +220,7 @@ model User {
|
||||
adminNotifications AdminNotification[] @relation("AdminNotificationCreator")
|
||||
ipBlocksCreated IPBlock[] @relation("IPBlockCreator")
|
||||
postViewLogs PostViewLog[] @relation("PostViewLogUser")
|
||||
couponRedemptions CouponRedemption[]
|
||||
|
||||
@@index([status])
|
||||
@@index([createdAt])
|
||||
@@ -583,3 +584,35 @@ model PasswordResetToken {
|
||||
@@index([userId, expiresAt])
|
||||
@@map("password_reset_tokens")
|
||||
}
|
||||
|
||||
// 쿠폰
|
||||
model Coupon {
|
||||
id String @id @default(cuid())
|
||||
code String @unique
|
||||
title String
|
||||
description String?
|
||||
stock Int @default(0) // 총 재고
|
||||
maxPerUser Int @default(1) // 1인당 제한
|
||||
expiresAt DateTime?
|
||||
active Boolean @default(true)
|
||||
createdAt DateTime @default(now())
|
||||
|
||||
redemptions CouponRedemption[]
|
||||
|
||||
@@index([active, expiresAt])
|
||||
@@map("coupons")
|
||||
}
|
||||
|
||||
model CouponRedemption {
|
||||
id String @id @default(cuid())
|
||||
couponId String
|
||||
userId String
|
||||
createdAt DateTime @default(now())
|
||||
|
||||
coupon Coupon @relation(fields: [couponId], references: [id], onDelete: Cascade)
|
||||
user User @relation(fields: [userId], references: [userId], onDelete: Cascade)
|
||||
|
||||
@@unique([couponId, userId])
|
||||
@@index([userId, createdAt])
|
||||
@@map("coupon_redemptions")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user