-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathschema.prisma
75 lines (67 loc) · 1.91 KB
/
schema.prisma
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
generator client {
provider = "dart run orm"
output = "lib/orm"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
model License {
license_key String @id
customer Customer @relation(fields: [customer_id], references:[id], onUpdate: Cascade, onDelete: Cascade)
customer_id Int
user_id String?
product Product @relation(fields: [product_id], references:[id], onUpdate: Cascade, onDelete: Cascade)
product_id Int
payments Payment[]
created_at DateTime @default(now())
}
model Product{
id Int @id @default(autoincrement())
name String
description String?
License License[]
features Feature[]
client_keys ClientKey[]
}
model Customer {
id Int @id @default(autoincrement())
name String
email String
licenses License[]
client_keys ClientKey[]
}
model Feature {
id Int @id @default(autoincrement())
name String
description String
type FeatureType
product Product @relation(fields: [product_id], references:[id], onUpdate: Cascade, onDelete: Cascade)
product_id Int
trial_period Int?
payments Payment[]
}
enum FeatureType {
FREE
PAID
}
model Payment {
id Int @id @default(autoincrement())
license License @relation(fields: [license_key], references: [license_key], onUpdate: Cascade, onDelete: Cascade)
license_key String
activation_date DateTime @default(now())
expiration_date DateTime
payment_reference String?
features Feature[]
revoked Boolean @default(false)
revocation_reasoning String?
}
model ClientKey {
id Int @id @default(autoincrement())
key String @unique
product Product @relation(fields: [product_id], references:[id], onUpdate: Cascade, onDelete: Cascade)
product_id Int
customer Customer @relation(fields: [customer_id], references:[id], onUpdate: Cascade, onDelete: Cascade)
customer_id Int
revoked Boolean @default(false)
}