-
Notifications
You must be signed in to change notification settings - Fork 50
/
schema.prisma
172 lines (151 loc) 路 5.15 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
// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
directUrl = env("DIRECT_DATABASE_URL")
shadowDatabaseUrl = env("SHADOW_DATABASE_URL")
}
model TemplateData {
id String @id @default(uuid()) @db.Uuid
semester Int
items TemplateItem[]
template Template @relation(fields: [templateId], references: [id], onDelete: Cascade)
templateId String @db.Uuid
}
model TemplateItem {
id String @id @default(uuid()) @db.Uuid
name String
type TemplateDataType @default(CORE)
templateData TemplateData @relation(fields: [templateDataId], references: [id], onDelete: Cascade)
templateDataId String @db.Uuid
}
model Template {
id String @id @default(uuid()) @db.Uuid
name String?
templateData TemplateData[]
}
model Profile {
id String @id @default(uuid()) @db.Uuid
name String
startYear Int
startSemester SemesterType
endYear Int
endSemester SemesterType
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
userId String @unique @db.Uuid
}
model Plan {
id String @id @default(uuid()) @db.Uuid
name String
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @default(now()) @map("updated_at")
semesters Semester[]
transferCredits String[]
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
userId String @db.Uuid
requirements DegreeRequirements?
startYear Int
startSemester SemesterType
endYear Int
endSemester SemesterType
}
// TODO(akevinge): Improve naming.
model DegreeRequirements {
id String @id @default(uuid()) @db.Uuid
major String // Change to String[] in future once modular requirements implemented; empty plan creates "undecided"
bypasses String[]
plan Plan @relation(fields: [planId], references: [id], onDelete: Cascade)
planId String @unique @db.Uuid
}
// TODO(akevinge): Remove.
model Bypass {
id String @id @default(uuid()) @db.Uuid
courseCode String
requirement String
hours Int
}
model Course {
id String @id @default(uuid()) @db.Uuid
code String
color String @default("")
semester Semester @relation(fields: [semesterId], references: [id], onDelete: Cascade)
semesterId String @db.Uuid
locked Boolean @default(false)
prereqOverriden Boolean @default(false)
@@unique([semesterId, code])
}
model Semester {
id String @id @default(uuid()) @db.Uuid
year Int
semester SemesterType
courses Course[]
plan Plan @relation(fields: [planId], references: [id], onDelete: Cascade)
planId String @db.Uuid
color String @default("")
locked Boolean @default(false)
}
// TODO(akevinge): Improve naming.
enum SemesterType {
f
s
u
}
// TODO(akevinge): Remove.
model AcademicDetails {
id Int @id @default(autoincrement())
}
// Necessary for Next auth
model Account {
id String @id @default(uuid()) @db.Uuid
type String
provider String
providerAccountId String
refresh_token String?
access_token String?
expires_at Int?
token_type String?
scope String?
id_token String?
session_state String?
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
userId String @db.Uuid
@@unique([provider, providerAccountId])
}
model Session {
id String @id @default(uuid()) @db.Uuid
sessionToken String @unique
expires DateTime
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
userId String @db.Uuid
}
model User {
id String @id @default(uuid()) @db.Uuid
email String? @unique
emailVerified DateTime?
onboardingComplete Boolean @default(false)
seenHomeOnboardingModal Boolean @default(false)
seenPlanOnboardingModal Boolean @default(false)
// Multiple accounts can be created when a user signs in with an OAuth provider
// while signed in with another provider. See: https://github.com/nextauthjs/next-auth/discussions/3116#discussioncomment-1622855.
accounts Account[]
sessions Session[]
profile Profile?
plans Plan[]
}
// VerificationToken is used by Auth.js (NextAuth) for passwordless sign via email.
// See: https://authjs.dev/reference/adapters#verification-token
model VerificationToken {
id Int @id @default(autoincrement())
identifier String
token String @unique
expires DateTime
@@unique([identifier, token])
}
enum TemplateDataType {
CORE
OPTIONAL
}