-
Notifications
You must be signed in to change notification settings - Fork 69
/
schema.prisma
154 lines (136 loc) · 5.03 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
generator client {
provider = "prisma-client-js"
previewFeatures = ["orderByRelation"]
}
datasource db {
provider = "postgresql"
url = env("DB_URL")
}
model Session {
id String @id
sid String @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])
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)
challenges Challenge[]
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])
mentor User @relation("starMentor", fields: [mentorId], references: [id])
student User @relation("starStudent", fields: [studentId], references: [id])
@@unique([studentId, lessonId])
@@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])
lesson Lesson @relation(fields: [lessonId], references: [id])
reviewer User? @relation("userReviewedSubmissions", fields: [reviewerId], references: [id])
user User @relation("userSubmissions", fields: [userId], references: [id])
comments Comment[]
@@map("submissions")
}
model Comment {
id Int @id @default(autoincrement())
fileName String?
line Int?
content String
authorId Int
author User @relation(fields: [authorId], references: [id])
submissionId Int
submission Submission @relation(fields: [submissionId], references: [id])
createdAt DateTime @default(now())
}
model UserLesson {
isPassed String? @db.VarChar(255)
isTeaching String? @db.VarChar(255)
isEnrolled String? @db.VarChar(255)
createdAt DateTime @default(now()) @db.Timestamptz(6)
updatedAt DateTime @updatedAt @db.Timestamptz(6)
lessonId Int
userId Int
lesson Lesson @relation(fields: [lessonId], references: [id])
user User @relation(fields: [userId], references: [id])
@@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)
starsMentor Star[] @relation("starMentor")
starsGiven Star[] @relation("starStudent")
submissionsReviewed Submission[] @relation("userReviewedSubmissions")
submissions Submission[] @relation("userSubmissions")
userLessons UserLesson[]
comments Comment[]
@@map("users")
}