-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathschema.prisma
326 lines (280 loc) · 9.1 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
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
datasource db {
provider = "mongodb"
url = env("DATABASE_URL")
relationMode = "prisma"
}
generator client {
provider = "prisma-client-js"
previewFeatures = ["fullTextSearch", "fullTextIndex", "referentialActions"]
}
enum Role {
USER
ADMIN
TEACHER
MENTOR
}
model User {
id String @id @default(auto()) @map("_id") @db.ObjectId
Submission Submission[]
name String?
email String
emailVerified DateTime? @map("email_verified")
image String? @default("https://utfs.io/f/851c7579-2eae-4519-a9ef-b9f573961121-nxkbtl.webp")
password String?
role Role @default(USER)
accounts Account[]
isTwoFactorEnabled Boolean @default(false)
twoFactorConfirmation TwoFactorConfirmation?
Editor Editor? @relation(fields: [editorId], references: [id])
editorId String? @db.ObjectId
Session Session[]
@@unique(email)
@@map("users")
}
model Session {
id String @id @default(auto()) @map("_id") @db.ObjectId
userId String
expires DateTime
sessionToken String @unique
accessToken String?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
user User @relation(fields: [userId], references: [id])
}
model Account {
id String @id @default(auto()) @map("_id") @db.ObjectId
userId String @map("user_id") @db.String
type String
provider String
providerAccountId String @map("provider_account_id")
refresh_token String? @db.String
access_token String? @db.String
expires_at Int?
token_type String?
scope String?
id_token String? @db.String
session_state String?
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@unique([provider, providerAccountId])
@@map("accounts")
}
model VerificationToken {
id String @id @default(auto()) @map("_id") @db.ObjectId
email String
token String @unique
expires DateTime
@@unique([email, token])
@@map("verificationtokens")
}
model PasswordResetToken {
id String @id @default(auto()) @map("_id") @db.ObjectId
email String
token String @unique
expires DateTime
@@unique([email, token])
}
model TwoFactorToken {
id String @id @default(auto()) @map("_id") @db.ObjectId
email String
token String @unique
expires DateTime
@@unique([email, token])
}
model TwoFactorConfirmation {
id String @id @default(auto()) @map("_id") @db.ObjectId
userId String
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@unique([userId])
}
model Course {
id String @id @default(auto()) @map("_id") @db.ObjectId
userId String
title String
description String?
imageUrl String?
price Float?
isPublished Boolean @default(false)
categoryId String?
category Category? @relation(fields: [categoryId], references: [id])
sections Section[]
attachments CourseAttachment[]
purchases Purchase[]
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@index([categoryId])
@@fulltext([title])
}
model Section {
id String @id @default(auto()) @map("_id") @db.ObjectId
title String
position Int
description String?
imageUrl String?
isPublished Boolean @default(false)
deadline DateTime @default(now())
weightage Float?
chapters Chapter[]
Course Course? @relation(fields: [courseId], references: [id])
courseId String? @db.ObjectId
}
model Category {
id String @id @default(auto()) @map("_id") @db.ObjectId
name String @unique
Course Course[]
}
model CourseAttachment {
id String @id @default(auto()) @map("_id") @db.ObjectId
name String
url String
courseId String
course Course @relation(fields: [courseId], references: [id], onDelete: Cascade)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@index([courseId])
}
model TopicTags {
id String @id @default(auto()) @map("_id") @db.ObjectId
name String @unique
}
enum Difficulty {
EASY
MEDIUM
HARD
GODLEVEL
}
model Company {
id String @id @default(auto()) @map("_id") @db.ObjectId
name String @unique
Editor Editor? @relation(fields: [editorId], references: [id])
editorId String? @db.ObjectId
}
model TestCase {
id String @id @default(auto()) @map("_id") @db.ObjectId
Input String
Output String
Explanation String?
exampleEditor Editor? @relation("example", fields: [exampleRuleId], references: [id], onDelete: NoAction, onUpdate: NoAction)
hiddenEditor Editor? @relation("hiddencases", fields: [hiddenRuleId], references: [id], onDelete: NoAction, onUpdate: NoAction)
exampleRuleId String?
hiddenRuleId String?
}
model CodingLanguage {
id String @id @default(auto()) @map("_id") @db.ObjectId
name String @unique
Submission Submission[]
Editor Editor? @relation(fields: [editorId], references: [id])
editorId String? @db.ObjectId
}
enum SubmissionStatus {
PENDING
ACCEPTED
REJECTED
}
enum SubmissionResult {
ACCEPTED
WRONG_ANSWER
MEMORY_LIMIT_EXCEEDED
OUTPUT_LIMIT_EXCEEDED
TIME_LIMIT_EXCEEDED
RUNTIME_ERROR
INTERNAL_ERROR
COMPILATION_ERROR
TIMEOUT
}
model Submission {
id String @id @default(auto()) @map("_id") @db.ObjectId
code String
language CodingLanguage @relation(fields: [languageId], references: [id])
languageId String
user User @relation(fields: [userId], references: [id])
userId String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
editorId String
editor Editor @relation(fields: [editorId], references: [id])
notes String
status SubmissionStatus
result SubmissionResult
runtime String
memory String
}
model Editor {
id String @id @default(auto()) @map("_id") @db.ObjectId
name String
description String?
difficulty Difficulty?
company Company[]
completeCode String?
starterCode String?
orginalCode String?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
constraints String[]
hints String[]
example TestCase[] @relation("example")
hiddencases TestCase[] @relation("hiddencases")
supportedLanguages CodingLanguage[]
submissions Submission[]
editorial String?
similarProblems Editor[] @relation("similar")
editor Editor? @relation("similar", fields: [editorId], references: [id], onDelete: NoAction, onUpdate: NoAction)
editorId String?
submittedBy User[]
Chapter Chapter[]
isPublished Boolean @default(false)
}
model Chapter {
id String @id @default(auto()) @map("_id") @db.ObjectId
title String
description String?
videoUrl String?
docUrl String?
position Int
isPublished Boolean @default(false)
isFree Boolean @default(false)
youtubeVideo String?
muxData MuxData?
userProgress UserProgress[]
isEditorBased Boolean @default(false)
editor Editor? @relation(fields: [editorId], references: [id])
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
Section Section? @relation(fields: [sectionId], references: [id])
sectionId String? @db.ObjectId
editorId String? @db.ObjectId
}
model MuxData {
id String @id @default(auto()) @map("_id") @db.ObjectId
assetId String
playbackId String?
chapterId String @unique
chapter Chapter @relation(fields: [chapterId], references: [id], onDelete: Cascade)
}
model UserProgress {
id String @id @default(auto()) @map("_id") @db.ObjectId
userId String
chapterId String
chapter Chapter @relation(fields: [chapterId], references: [id], onDelete: Cascade)
isCompleted Boolean @default(false)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@unique([userId, chapterId])
@@index([chapterId])
}
model Purchase {
id String @id @default(auto()) @map("_id") @db.ObjectId
userId String
courseId String
course Course @relation(fields: [courseId], references: [id], onDelete: Cascade)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt()
@@unique([userId, courseId])
@@index([courseId])
}
model StripeCustomer {
id String @id @default(auto()) @map("_id") @db.ObjectId
userId String @unique
stripeCustomerId String @unique
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}