-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Expand file tree
/
Copy pathdiscount.prisma
More file actions
49 lines (43 loc) · 1.83 KB
/
Copy pathdiscount.prisma
File metadata and controls
49 lines (43 loc) · 1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
enum DiscountProvider {
stripe
shopify
}
model Discount {
id String @id
programId String
amount Int @default(0)
type RewardStructure @default(percentage)
maxDuration Int? // in months (0 -> one-time purchase, 1, 3, 6, 12, 24 -> months, null -> lifetime)
description String?
couponId String?
couponTestId String?
autoProvisionEnabledAt DateTime? // Auto create discount codes for partners when they join the group
provider DiscountProvider @default(stripe)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
programEnrollments ProgramEnrollment[]
program Program @relation("ProgramDiscounts", fields: [programId], references: [id])
partnerGroup PartnerGroup?
discountCodes DiscountCode[]
@@index(programId)
}
model DiscountCode {
id String @id
code String
programId String
discountId String?
partnerId String
linkId String @unique
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
disabledAt DateTime?
program Program @relation(fields: [programId], references: [id], onDelete: Cascade)
discount Discount? @relation(fields: [discountId], references: [id], onDelete: SetNull)
partner Partner @relation(fields: [partnerId], references: [id])
link Link @relation(fields: [linkId], references: [id])
programEnrollment ProgramEnrollment? @relation(fields: [programId, partnerId], references: [programId, partnerId], onDelete: Cascade)
@@unique([programId, code])
@@index([programId, partnerId])
@@index(discountId)
@@index(partnerId)
}