-
Notifications
You must be signed in to change notification settings - Fork 69
/
schema.prisma
227 lines (203 loc) · 8.48 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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
url = env("DB_URL")
}
model Session {
id String @id
sid String @unique(map: "Session.sid_unique")
data String
expiresAt DateTime
createdAt DateTime @default(now()) @db.Timestamptz(6)
updatedAt DateTime @updatedAt @db.Timestamptz(6)
}
model Alert {
id Int @id @default(autoincrement())
text String? @db.VarChar(255)
type String? @db.VarChar(255)
url String? @db.VarChar(255)
urlCaption String? @db.VarChar(255)
createdAt DateTime @default(now()) @db.Timestamptz(6)
updatedAt DateTime @updatedAt @db.Timestamptz(6)
@@map("alerts")
}
model Challenge {
id Int @id @default(autoincrement())
description String
title String @db.VarChar(255)
order Int
createdAt DateTime @default(now()) @db.Timestamptz(6)
updatedAt DateTime @updatedAt @db.Timestamptz(6)
lessonId Int
lesson Lesson @relation(fields: [lessonId], references: [id], onDelete: Cascade, map: "challenges_lessonId_fk")
submissions Submission[]
@@map("challenges")
}
model Lesson {
id Int @id @default(autoincrement())
description String
docUrl String? @db.VarChar(255)
githubUrl String? @db.VarChar(255)
videoUrl String? @db.VarChar(255)
order Int
title String @db.VarChar(255)
createdAt DateTime @default(now()) @db.Timestamptz(6)
updatedAt DateTime @updatedAt @db.Timestamptz(6)
chatUrl String? @db.VarChar(255)
slug String @unique(map: "lessons.slug_unique") @db.VarChar(50)
challenges Challenge[]
modules Module[]
starLesson Star[] @relation("starLesson")
submissions Submission[]
userLessons UserLesson[]
@@map("lessons")
}
model Star {
id Int @id @default(autoincrement())
lessonId Int
createdAt DateTime @default(now()) @db.Timestamptz(6)
updatedAt DateTime @updatedAt @db.Timestamptz(6)
studentId Int
mentorId Int
comment String? @db.VarChar(255)
lesson Lesson @relation("starLesson", fields: [lessonId], references: [id], onDelete: Cascade)
mentor User @relation("starMentor", fields: [mentorId], references: [id], onDelete: Cascade)
student User @relation("starStudent", fields: [studentId], references: [id], onDelete: Cascade)
@@unique([studentId, lessonId], map: "stars.studentId_lessonId_unique")
@@map("stars")
}
model Submission {
id Int @id @default(autoincrement())
mrUrl String? @db.VarChar(255)
diff String?
comment String?
status String @default("open") @db.VarChar(255)
viewCount Int? @default(0)
createdAt DateTime @default(now()) @db.Timestamptz(6)
updatedAt DateTime @updatedAt @db.Timestamptz(6)
userId Int
reviewerId Int?
challengeId Int
lessonId Int
challenge Challenge @relation(fields: [challengeId], references: [id], onDelete: Cascade)
lesson Lesson @relation(fields: [lessonId], references: [id], onDelete: Cascade)
reviewer User? @relation("userReviewedSubmissions", fields: [reviewerId], references: [id])
user User @relation("userSubmissions", fields: [userId], references: [id], onDelete: Cascade)
comments Comment[]
@@map("submissions")
}
model Comment {
id Int @id @default(autoincrement())
fileName String?
line Int?
content String
authorId Int
submissionId Int
createdAt DateTime @default(now())
author User @relation(fields: [authorId], references: [id], onDelete: Cascade)
submission Submission @relation(fields: [submissionId], references: [id], onDelete: Cascade)
}
model UserLesson {
passedAt DateTime? @db.Timestamptz(6)
createdAt DateTime @default(now()) @db.Timestamptz(6)
updatedAt DateTime @updatedAt @db.Timestamptz(6)
lessonId Int
userId Int
lesson Lesson @relation(fields: [lessonId], references: [id], onDelete: Cascade)
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@id([lessonId, userId])
@@map("userLessons")
}
model User {
id Int @id @default(autoincrement())
name String @db.VarChar(255)
username String @db.VarChar(255)
password String? @db.VarChar(255)
email String @db.VarChar(255)
gsId Int?
isOnline Boolean?
createdAt DateTime @default(now()) @db.Timestamptz(6)
updatedAt DateTime @updatedAt @db.Timestamptz(6)
isAdmin Boolean @default(false)
forgotToken String? @db.VarChar(255)
cliToken String? @db.VarChar(255)
emailVerificationToken String? @db.VarChar(255)
tokenExpiration DateTime? @db.Timestamptz(6)
discordRefreshToken String? @db.VarChar(255)
discordAccessToken String? @db.VarChar(255)
discordAccessTokenExpires DateTime? @db.Timestamptz(6)
discordId String? @db.VarChar(255)
cliVersion String? @db.VarChar(255)
comments Comment[]
exercises Exercise[]
exerciseSubmissions ExerciseSubmission[]
Exercise Exercise[] @relation("flaggedExercises")
modules Module[]
starsMentor Star[] @relation("starMentor")
starsGiven Star[] @relation("starStudent")
submissionsReviewed Submission[] @relation("userReviewedSubmissions")
submissions Submission[] @relation("userSubmissions")
userLessons UserLesson[]
exerciseComments ExerciseComment[]
@@map("users")
}
model Module {
id Int @id @default(autoincrement())
createdAt DateTime @default(now()) @db.Timestamptz(6)
updatedAt DateTime @updatedAt @db.Timestamptz(6)
authorId Int
lessonId Int
name String @db.VarChar(255)
content String
order Int
author User @relation(fields: [authorId], references: [id], onDelete: Cascade)
lesson Lesson @relation(fields: [lessonId], references: [id], onDelete: Cascade)
exercises Exercise[]
@@map("modules")
}
model Exercise {
id Int @id @default(autoincrement())
createdAt DateTime @default(now()) @db.Timestamptz(6)
updatedAt DateTime @updatedAt @db.Timestamptz(6)
authorId Int
moduleId Int
description String
answer String
testStr String?
explanation String?
removed Boolean? @default(false)
flagReason String?
flaggedAt DateTime?
flaggedById Int?
author User @relation(fields: [authorId], references: [id], onDelete: Cascade)
flaggedBy User? @relation("flaggedExercises", fields: [flaggedById], references: [id])
module Module @relation(fields: [moduleId], references: [id], onDelete: Cascade)
submissions ExerciseSubmission[]
exerciseComments ExerciseComment[]
@@map("exercises")
}
model ExerciseSubmission {
id Int @id @default(autoincrement())
exerciseId Int
exercise Exercise @relation(fields: [exerciseId], references: [id], onDelete: Cascade)
userId Int
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
userAnswer String
@@map("exerciseSubmissions")
}
model ExerciseComment {
id Int @id @default(autoincrement())
createdAt DateTime @default(now()) @db.Timestamptz(6)
updatedAt DateTime @updatedAt @db.Timestamptz(6)
authorId Int
exerciseId Int
userPic String?
content String
parentId Int?
exercise Exercise @relation(fields: [exerciseId], references: [id], onDelete: Cascade)
author User @relation(fields: [authorId], references: [id], onDelete: SetNull)
parent ExerciseComment? @relation("ExerciseCommentReplies", fields: [parentId], references: [id])
replies ExerciseComment[] @relation("ExerciseCommentReplies")
}