-
Notifications
You must be signed in to change notification settings - Fork 10
/
schema.prisma
219 lines (195 loc) · 7.78 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
// This file is automatically generated by Keystone, do not modify it manually.
// Modify your Keystone config when you want to change this.
datasource postgresql {
url = env("DATABASE_URL")
shadowDatabaseUrl = env("SHADOW_DATABASE_URL")
provider = "postgresql"
}
generator client {
provider = "prisma-client-js"
previewFeatures = ["driverAdapters"]
}
model User {
id String @id @default(cuid())
email String @default("")
emailVerified Boolean @default(false)
emailVerificationToken String @default("")
emailVerificationTokenExpiry DateTime?
provider String
password String?
subjectId String @unique @default("")
createdAt DateTime? @default(now())
account Account? @relation("Account_user")
role String @default("ACCOUNT")
}
model Account {
id String @id @default(cuid())
user User? @relation("Account_user", fields: [userId], references: [id])
userId String? @unique @map("user")
firstName String @default("PLEASE_UPDATE")
surname String @default("PLEASE_UPDATE")
phone String @default("PLEASE_UPDATE")
secondContactName String @default("PLEASE_UPDATE")
secondContactPhone String @default("PLEASE_UPDATE")
students Student[] @relation("Student_account")
bills Bill[] @relation("Bill_account")
streetAddress String @default("PLEASE_UPDATE")
suburb String @default("PLEASE_UPDATE")
postcode Int @default(3550)
xeroId String? @unique
createdAt DateTime? @default(now())
}
model Student {
id String @id @default(cuid())
firstName String @default("")
surname String @default("")
dateOfBirth DateTime @postgresql.Date
school String
yearLevel Int
medical String? @postgresql.Text
account Account? @relation("Student_account", fields: [accountId], references: [id])
accountId String? @map("account")
enrolments Enrolment[] @relation("Enrolment_student")
createdAt DateTime? @default(now())
@@index([accountId])
}
model LessonCategory {
id String @id @default(cuid())
name String @default("")
slug String @unique @default("")
cost String @default("")
type String
length String @default("")
description String? @postgresql.Text
xeroAccountCode String? @unique
lessons Lesson[] @relation("Lesson_lessonCategory")
}
model ImportantDate {
id String @id @default(cuid())
name String @default("")
date DateTime @postgresql.Date
brief String @default("")
description String? @postgresql.Text
}
model Term {
id String @id @default(cuid())
name String @default("")
quantity Int
year Int
startDate DateTime @postgresql.Date
endDate DateTime @postgresql.Date
lessonTerms LessonTerm[] @relation("LessonTerm_term")
termStatus String?
copyFrom Term? @relation("Term_copyFrom", fields: [copyFromId], references: [id], onDelete: NoAction, onUpdate: NoAction)
copyFromId String? @map("copyFrom")
from_Term_copyFrom Term[] @relation("Term_copyFrom")
from_Bill_term Bill[] @relation("Bill_term")
@@index([copyFromId])
}
model LessonTerm {
id String @id @default(cuid())
status String
term Term? @relation("LessonTerm_term", fields: [termId], references: [id])
termId String? @map("term")
lesson Lesson? @relation("LessonTerm_lesson", fields: [lessonId], references: [id])
lessonId String? @map("lesson")
enrolments Enrolment[] @relation("Enrolment_lessonTerm")
messages Message[] @relation("LessonTerm_messages")
numberOfLessons Int @default(0)
createdAt DateTime? @default(now())
@@index([termId])
@@index([lessonId])
}
model Lesson {
id String @id @default(cuid())
name String @default("")
lessonCategory LessonCategory? @relation("Lesson_lessonCategory", fields: [lessonCategoryId], references: [id])
lessonCategoryId String? @map("lessonCategory")
description String? @postgresql.Text
cost Int
time String @default("")
lengthMin Int
day String
minYear Int
maxYear Int
location String @default("")
createdAt DateTime? @default(now())
lessonTerms LessonTerm[] @relation("LessonTerm_lesson")
teachers Teacher[] @relation("Lesson_teachers")
@@index([lessonCategoryId])
}
model EmailSettings {
id Int @id
fromEmail String @default("")
enrolmentConfirmationTemplate String @default("")
lessonTermMessageTemplate String @default("")
}
model XeroSettings {
id Int @id
tokenSet Json?
tenantId String @default("")
}
model Teacher {
id String @id @default(cuid())
name String @default("")
bio String? @postgresql.Text
position String @default("")
image_filesize Int?
image_pathname String?
image_width Int?
image_height Int?
image_contentType String?
image_contentDisposition String?
image_url String?
lessons Lesson[] @relation("Lesson_teachers")
}
model Enrolment {
id String @id @default(cuid())
lessonTerm LessonTerm? @relation("Enrolment_lessonTerm", fields: [lessonTermId], references: [id])
lessonTermId String? @map("lessonTerm")
student Student? @relation("Enrolment_student", fields: [studentId], references: [id])
studentId String? @map("student")
status String
billItem BillItem? @relation("BillItem_enrolment")
createdAt DateTime? @default(now())
@@index([lessonTermId])
@@index([studentId])
}
model Message {
id String @id @default(cuid())
name String @default("")
status String @default("DRAFT")
content String? @postgresql.Text
lessonTerms LessonTerm[] @relation("LessonTerm_messages")
sentAt DateTime?
createdAt DateTime? @default(now())
}
model Bill {
id String @id @default(cuid())
name String @default("")
account Account? @relation("Bill_account", fields: [accountId], references: [id])
accountId String? @map("account")
date DateTime? @postgresql.Date
dueDate DateTime? @postgresql.Date
status String
term Term? @relation("Bill_term", fields: [termId], references: [id])
termId String? @map("term")
items BillItem[] @relation("BillItem_bill")
xeroId String? @unique
createdAt DateTime? @default(now())
@@index([accountId])
@@index([termId])
}
model BillItem {
id String @id @default(cuid())
name String @default("")
bill Bill? @relation("BillItem_bill", fields: [billId], references: [id])
billId String? @map("bill")
quantity Int @default(1)
amount Int
enrolment Enrolment? @relation("BillItem_enrolment", fields: [enrolmentId], references: [id])
enrolmentId String? @unique @map("enrolment")
xeroId String? @unique
createdAt DateTime? @default(now())
@@index([billId])
}