-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathschema.prisma
More file actions
513 lines (418 loc) · 15.2 KB
/
schema.prisma
File metadata and controls
513 lines (418 loc) · 15.2 KB
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
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
generator client {
provider = "prisma-client-js"
previewFeatures = ["metrics", "tracing", "jsonprotocol", "extendedWhereUnique"]
binaryTargets = ["native", "linux-musl-openssl-3.0.x"]
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
enum UserRole {
ADMIN
MENTOR
STUDENT
EO
UNIT
}
enum Gender {
MALE
FEMALE
}
enum Campus {
GANESHA
JATINANGOR
CIREBON
}
enum Status {
HADIR
TIDAK_HADIR
IZIN_DITERIMA
IZIN_PENDING
IZIN_DITOLAK
}
enum Lembaga {
HMJ
UKM
BSO
PUSAT
PENGMAS
}
enum AssignmentType {
MANDATORY
DAILY_QUEST
SIDE_QUEST
}
model User {
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
nim String @unique
passwordHash String
role UserRole @default(STUDENT)
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
profile Profile?
unitProfile UnitProfile?
friendInitiated Friendship[] @relation("initiator")
friendReceived Friendship[] @relation("receiver")
sentMessages Message[] @relation("sender")
receivedMessages Message[] @relation("receiver")
firstUserRoom RoomChat[] @relation("firstUserRoom")
secondUserRoom RoomChat[] @relation("secondUserRoom")
ResetToken ResetToken[]
student StudentMentor[] @relation("student")
mentor StudentMentor[] @relation("mentor")
groupRelation GroupRelation[] @relation("group")
attendance AttendanceRecord[] @relation("attendance")
submission AssignmentSubmission[] @relation("submission")
firstMatch UserMatch[] @relation("firstMatch")
secondMatch UserMatch[] @relation("secondMatch")
ChatReport ChatReport[]
FeedReaction FeedReaction[]
FeedRead FeedRead[]
SendUnitVisit UnitVisit[] @relation("unit")
ReceiveUnitVisit UnitVisit[] @relation("student")
SendUnitReward UnitReward[] @relation("sender")
ReceiveUnitReward UnitReward[] @relation("receiver")
MerchandiseRequest MerchandiseRequest[]
MerchandiseCheckout MerchandiseCheckout[]
@@unique([createdAt, id]) // Unique for cursor pagination
}
model Profile {
userId String @id @db.Uuid
user User @relation(fields: [userId], references: [id])
name String
pin String @unique @db.Char(6)
faculty String? @db.VarChar(50)
gender Gender?
campus Campus?
email String? @unique
image String?
bio String @default("")
instagram String?
visitedCount Int @default(0)
friendCount Int @default(0)
point Int @default(0)
coin Int @default(0)
updatedAt DateTime @default(now()) @updatedAt
@@index([point(sort: Desc), name(sort: Desc)])
@@index([pin])
}
model ResetToken {
userId String @id @db.Uuid
user User @relation(fields: [userId], references: [id], onDelete: Cascade, onUpdate: Cascade)
token String
createdAt DateTime @default(now()) @db.Timestamp()
expireTime Int @default(3600) // 1 hour
}
model Friendship {
userInitiatorId String @db.Uuid
userInitiator User @relation("initiator", fields: [userInitiatorId], references: [id])
userReceiverId String @db.Uuid
userReceiver User @relation("receiver", fields: [userReceiverId], references: [id])
createdAt DateTime @default(now())
accepted Boolean @default(false)
@@id([userInitiatorId, userReceiverId])
}
model Message {
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
senderId String @db.Uuid
sender User @relation("sender", fields: [senderId], references: [id])
receiverId String @db.Uuid
receiver User @relation("receiver", fields: [receiverId], references: [id])
message String
createdAt DateTime @default(now())
userMatchId String? @db.Uuid
userMatch UserMatch? @relation(fields: [userMatchId], references: [id])
roomChatId Int?
roomChat RoomChat? @relation(fields: [roomChatId], references: [id])
isRead Boolean @default(false)
@@unique([createdAt, id]) // Unique for cursor pagination
@@index([userMatchId])
@@index([createdAt(sort: Desc)])
@@index([receiverId, senderId])
@@index([roomChatId])
}
// Dashboard Internal
model StudentMentor {
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
studentId String @db.Uuid
mentorId String @db.Uuid
student User @relation("student", fields: [studentId], references: [id])
mentor User @relation("mentor", fields: [mentorId], references: [id])
}
model Group {
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
group Int
groupRelation GroupRelation[] @relation("group")
}
model GroupRelation {
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
userId String @db.Uuid
groupId String @db.Uuid
user User @relation("group", fields: [userId], references: [id])
group Group @relation("group", fields: [groupId], references: [id])
}
model AttendanceRecord {
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
date DateTime
status Status @default(TIDAK_HADIR)
reason String? @db.Text
studentId String @db.Uuid
eventId String @db.Uuid
student User @relation("attendance", fields: [studentId], references: [id])
event AttendanceEvent @relation("event", fields: [eventId], references: [id], onDelete: Cascade)
@@unique([studentId, eventId])
@@index([studentId])
}
model AttendanceEvent {
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
title String @db.VarChar(50)
startTime DateTime
endTime DateTime
dayId String @db.Uuid
day AttendanceDay @relation(fields: [dayId], references: [id], onDelete: Cascade)
record AttendanceRecord[] @relation("event")
}
model AttendanceDay {
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
name String @db.VarChar(50)
time DateTime @db.Date
event AttendanceEvent[]
}
model Assignment {
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
type AssignmentType @default(MANDATORY)
title String @db.VarChar(50)
filePath String? @db.VarChar(255)
description String? @db.Text
startTime DateTime
endTime DateTime
submission AssignmentSubmission[] @relation("submission")
}
model AssignmentSubmission {
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
filePath String? @db.VarChar(255)
score Int?
createdAt DateTime @default(now())
studentId String @db.Uuid
assignmentId String @db.Uuid
student User @relation("submission", fields: [studentId], references: [id])
assignment Assignment @relation("submission", fields: [assignmentId], references: [id], onDelete: Cascade)
@@unique([studentId, assignmentId])
@@index([studentId])
}
model ShortenedLink {
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
source String @unique @db.VarChar(255)
destination String @unique @db.VarChar(255)
clickCount Int @default(0)
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
}
model UserMatch {
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
firstUserId String @db.Uuid
firstUser User @relation("firstMatch", fields: [firstUserId], references: [id])
secondUserId String @db.Uuid
secondUser User @relation("secondMatch", fields: [secondUserId], references: [id])
createdAt DateTime @default(now())
isRevealed Boolean @default(false)
topic String?
endedAt DateTime?
messages Message[]
ChatReport ChatReport[]
@@index([firstUserId, secondUserId])
@@index([firstUserId])
@@index([secondUserId])
@@index([endedAt])
}
model ChatReport {
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
reportedUserId String @db.Uuid
reportedUser User @relation(fields: [reportedUserId], references: [id])
userMatchId String @db.Uuid
userMatch UserMatch @relation(fields: [userMatchId], references: [id])
message String
isResolved Boolean @default(false)
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
}
model ITBGotTalent {
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
day String @db.VarChar(255)
time String @db.VarChar(255)
registrant ITBGotTalentRegistrant?
}
model ITBGotTalentRegistrant {
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
scheduleId String @unique @db.Uuid
teamName String @db.VarChar(255)
contact String
teamMember String[]
ktmPath String @db.VarChar(255)
musicPath String? @db.VarChar(255)
property String[]
schedule ITBGotTalent @relation(fields: [scheduleId], references: [id])
}
model ShowcaseBooking {
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
name String @db.VarChar(255)
nim String @unique
lembaga Lembaga @default(PUSAT)
lembagaName String @db.VarChar(255)
position String @db.VarChar(255)
secondPartyName String @db.VarChar(255)
secondPartyPosition String @db.VarChar(255)
secondPartyContact String @db.VarChar(255)
fakultas String @db.VarChar(255)
jurusan String @db.VarChar(255)
angkatan String @db.VarChar(255)
lineId String @db.VarChar(255)
waNumber String @db.VarChar(255)
noise Boolean @default(false)
kaos Json[] @db.Json
total Int
method String @db.VarChar(255)
mouPath String @db.VarChar(255)
proofPath String @db.VarChar(255)
createdAt DateTime @default(now())
}
model LocationBooking {
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
token String @unique @db.VarChar(50)
locations String[] @db.VarChar(50)
}
model BookedLocation {
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
token String @unique
location String @unique @db.VarChar(50)
}
model UnitProfile {
userId String @id @db.Uuid
user User @relation(fields: [userId], references: [id])
name String
lembaga Lembaga @default(PUSAT)
pin String @unique @db.Char(6)
group String?
image String?
bio String @default("")
visitedCount Int @default(0)
updatedAt DateTime @default(now()) @updatedAt
@@index([pin])
}
model UnitVisit {
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
studentId String @db.Uuid
unitId String @db.Uuid
createdAt DateTime @default(now())
student User @relation("student", fields: [studentId], references: [id])
unit User @relation("unit", fields: [unitId], references: [id])
@@unique([studentId, unitId])
}
model UnitReward {
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
studentId String @db.Uuid
unitId String @db.Uuid
reward Int @default(0) // Digunakan untuk audit (berasal dari EO)
createdAt DateTime @default(now())
student User @relation("sender", fields: [studentId], references: [id])
unit User @relation("receiver", fields: [unitId], references: [id])
}
model Merchandise {
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
name String
price Int @default(0)
stock Int @default(0)
isPublished Boolean @default(false)
image String?
updatedAt DateTime @default(now()) @updatedAt
MerchandiseRequest MerchandiseRequest[]
}
model MerchandiseRequest {
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
studentId String @db.Uuid
merchId String @db.Uuid
merchCheckoutId String @db.Uuid
quantity Int @default(0)
isApproved Boolean @default(false)
createdAt DateTime @default(now())
student User @relation(fields: [studentId], references: [id])
merch Merchandise @relation(fields: [merchId], references: [id])
merchCheckout MerchandiseCheckout @relation(fields: [merchCheckoutId], references: [id])
@@unique([studentId, merchId, merchCheckoutId])
}
model MerchandiseCheckout {
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
studentId String @db.Uuid
amount Int @default(0) // Digunakan untuk audit (agregat dari price * quantity)
createdAt DateTime @default(now())
student User @relation(fields: [studentId], references: [id])
MerchandiseRequest MerchandiseRequest[]
}
model Feed {
id Int @id @default(autoincrement())
text String
attachmentUrl String?
createdAt DateTime @default(now())
feedReactions FeedReaction[]
feedReads FeedRead[]
}
model FeedReaction {
feed Feed @relation(fields: [feedId], references: [id], onDelete: Cascade)
user User @relation(fields: [userId], references: [id])
reaction String @db.VarChar(255)
feedId Int
userId String @db.Uuid
@@id([feedId, userId, reaction])
@@index([feedId])
}
model FeedRead {
feed Feed @relation(fields: [feedId], references: [id], onDelete: Cascade)
user User @relation(fields: [userId], references: [id])
createdAt DateTime @default(now())
feedId Int
userId String @db.Uuid
@@id([userId, feedId])
@@index([feedId])
}
model Map {
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
campus String @unique @db.VarChar(255)
description String? @db.Text
baseLatitude Decimal @db.Decimal(8, 6)
baseLongitude Decimal @db.Decimal(9, 6)
MapLocation MapLocation[]
}
model MapLocation {
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
title String @unique @db.VarChar(255)
subtitle String? @db.VarChar(255)
description String? @db.Text
baseLatitude Decimal @db.Decimal(8, 6)
baseLongitude Decimal @db.Decimal(9, 6)
mapId String @db.Uuid
logo String? @db.VarChar(255)
Map Map @relation(fields: [mapId], references: [id])
MapPhoto MapPhoto[]
}
model MapPhoto {
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
imageUrl String @db.VarChar(255)
caption String? @db.VarChar(255)
mapLocationId String @db.Uuid
MapLocation MapLocation @relation(fields: [mapLocationId], references: [id])
}
model RoomChat {
id Int @id @default(autoincrement())
firstUserId String @db.Uuid
secondUserId String @db.Uuid
firstUser User @relation("firstUserRoom", fields: [firstUserId], references: [id])
secondUser User @relation("secondUserRoom", fields: [secondUserId], references: [id])
Message Message[]
@@unique([firstUserId, secondUserId])
}
model Article {
id String @id
likes Int @default(0)
views Int @default(0)
@@unique([id])
}