-
Notifications
You must be signed in to change notification settings - Fork 20
/
schema.prisma
109 lines (101 loc) · 3.47 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
generator client {
provider = "prisma-client-js"
previewFeatures = ["referentialIntegrity"]
}
datasource db {
provider = "mysql"
url = env("DATABASE_URL")
referentialIntegrity = "prisma"
}
model User {
id String @id @default(uuid())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
email String @unique(map: "User.email_unique")
name String?
phoneNumber String?
telegram String?
instagram String?
role String
courses Course[]
subscriptions Subscription[] @relation("UserSubscriptions")
subscribers Subscription[] @relation("UserSubscribers")
transactions Transaction[] @relation("UserTransactions")
sales Transaction[] @relation("UserSales")
}
model Subscription {
id String @id @default(uuid())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
userId String
authorId String
courseId String
status String
course Course @relation(fields: [courseId], references: [id], onDelete: Cascade)
user User @relation("UserSubscriptions", fields: [userId], references: [id], onDelete: Cascade)
author User @relation("UserSubscribers", fields: [authorId], references: [id], onDelete: Cascade)
}
model Course {
id String @id @default(uuid())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
authorId String
name String
description String
price Int
image String
category String
author User @relation(fields: [authorId], references: [id], onDelete: Cascade)
subscriptions Subscription[]
transactions Transaction[]
chapters Chapter[]
}
model Transaction {
id String @id @default(uuid())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
userId String
courseId String
authorId String
bankName String
bankAccountNumber String
bankAccountName String
amount Int
datetime DateTime?
status String
notes String? @db.Text
user User @relation("UserTransactions", fields: [userId], references: [id], onDelete: Cascade)
author User @relation("UserSales", fields: [authorId], references: [id], onDelete: Cascade)
course Course @relation(fields: [courseId], references: [id], onDelete: Cascade)
}
model Chapter {
id String @id @default(uuid())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
courseId String
name String
order Int
course Course @relation(fields: [courseId], references: [id], onDelete: Cascade)
lessons Lesson[]
}
model Lesson {
id String @id @default(uuid())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
chapterId String
name String
description String? @db.Text
videoId String
order Int
chapter Chapter @relation(fields: [chapterId], references: [id], onDelete: Cascade)
attachments Attachment[]
}
model Attachment {
id String @id @default(uuid())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
name String
url String
lessonId String
lesson Lesson @relation(fields: [lessonId], references: [id], onDelete: Cascade)
}