257 lines
6.8 KiB
Plaintext
257 lines
6.8 KiB
Plaintext
generator client {
|
|
provider = "prisma-client-js"
|
|
}
|
|
|
|
datasource db {
|
|
provider = "mysql"
|
|
url = env("DATABASE_URL")
|
|
}
|
|
|
|
model admins {
|
|
id String @id
|
|
userId String @unique
|
|
name String
|
|
phone String?
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime
|
|
users users @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
}
|
|
|
|
model attendance_sessions {
|
|
id String @id
|
|
scheduleId String
|
|
date DateTime @db.Date
|
|
startTime DateTime
|
|
endTime DateTime
|
|
qrCode String? @unique
|
|
qrExpiredAt DateTime?
|
|
topic String?
|
|
notes String? @db.Text
|
|
isActive Boolean @default(true)
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime
|
|
schedules schedules @relation(fields: [scheduleId], references: [id], onDelete: Cascade)
|
|
attendances attendances[]
|
|
|
|
@@unique([scheduleId, date])
|
|
}
|
|
|
|
model attendances {
|
|
id String @id
|
|
sessionId String
|
|
studentId String
|
|
status attendances_status @default(PRESENT)
|
|
checkInTime DateTime @default(now())
|
|
ipAddress String?
|
|
latitude Float?
|
|
longitude Float?
|
|
deviceInfo String? @db.Text
|
|
notes String? @db.Text
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime
|
|
attendance_sessions attendance_sessions @relation(fields: [sessionId], references: [id], onDelete: Cascade)
|
|
students students @relation(fields: [studentId], references: [id], onDelete: Cascade)
|
|
|
|
@@unique([sessionId, studentId])
|
|
@@index([studentId], map: "attendances_studentId_fkey")
|
|
}
|
|
|
|
model audit_logs {
|
|
id String @id
|
|
userId String
|
|
action String
|
|
entity String
|
|
entityId String
|
|
oldValue String? @db.Text
|
|
newValue String? @db.Text
|
|
ipAddress String?
|
|
userAgent String? @db.Text
|
|
createdAt DateTime @default(now())
|
|
}
|
|
|
|
model classes {
|
|
id String @id
|
|
name String @unique
|
|
grade String
|
|
major String?
|
|
capacity Int @default(40)
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime
|
|
schedules schedules[]
|
|
students students[]
|
|
}
|
|
|
|
model courses {
|
|
id String @id
|
|
code String @unique
|
|
name String
|
|
description String? @db.Text
|
|
teacherId String
|
|
credits Int @default(2)
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime
|
|
teachers teachers @relation(fields: [teacherId], references: [id], onDelete: Cascade)
|
|
schedules schedules[]
|
|
|
|
@@index([teacherId], map: "courses_teacherId_fkey")
|
|
}
|
|
|
|
model leave_requests {
|
|
id String @id
|
|
studentId String
|
|
startDate DateTime @db.Date
|
|
endDate DateTime @db.Date
|
|
type leave_requests_type
|
|
reason String @db.Text
|
|
attachment String?
|
|
status leave_requests_status @default(PENDING)
|
|
reviewedBy String?
|
|
reviewedAt DateTime?
|
|
reviewNotes String? @db.Text
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime
|
|
students students @relation(fields: [studentId], references: [id], onDelete: Cascade)
|
|
|
|
@@index([studentId], map: "leave_requests_studentId_fkey")
|
|
}
|
|
|
|
model notifications {
|
|
id String @id
|
|
userId String
|
|
type notifications_type
|
|
title String
|
|
message String @db.Text
|
|
isRead Boolean @default(false)
|
|
createdAt DateTime @default(now())
|
|
}
|
|
|
|
model schedules {
|
|
id String @id
|
|
courseId String
|
|
classId String
|
|
teacherId String
|
|
dayOfWeek schedules_dayOfWeek
|
|
startTime String
|
|
endTime String
|
|
room String?
|
|
wifiNetworkId String?
|
|
isActive Boolean @default(true)
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime
|
|
attendance_sessions attendance_sessions[]
|
|
classes classes @relation(fields: [classId], references: [id], onDelete: Cascade)
|
|
courses courses @relation(fields: [courseId], references: [id], onDelete: Cascade)
|
|
teachers teachers @relation(fields: [teacherId], references: [id], onDelete: Cascade)
|
|
wifi_networks wifi_networks? @relation(fields: [wifiNetworkId], references: [id])
|
|
|
|
@@index([classId], map: "schedules_classId_fkey")
|
|
@@index([courseId], map: "schedules_courseId_fkey")
|
|
@@index([teacherId], map: "schedules_teacherId_fkey")
|
|
@@index([wifiNetworkId], map: "schedules_wifiNetworkId_fkey")
|
|
}
|
|
|
|
model students {
|
|
id String @id
|
|
userId String @unique
|
|
nis String @unique
|
|
name String
|
|
phone String?
|
|
address String? @db.Text
|
|
photo String?
|
|
classId String?
|
|
parentPhone String?
|
|
parentEmail String?
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime
|
|
attendances attendances[]
|
|
leave_requests leave_requests[]
|
|
classes classes? @relation(fields: [classId], references: [id])
|
|
users users @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
|
|
@@index([classId], map: "students_classId_fkey")
|
|
}
|
|
|
|
model teachers {
|
|
id String @id
|
|
userId String @unique
|
|
nip String @unique
|
|
name String
|
|
phone String?
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime
|
|
courses courses[]
|
|
schedules schedules[]
|
|
users users @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
}
|
|
|
|
model users {
|
|
id String @id
|
|
email String @unique
|
|
password String
|
|
role users_role @default(STUDENT)
|
|
isActive Boolean @default(true)
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime
|
|
admins admins?
|
|
students students?
|
|
teachers teachers?
|
|
}
|
|
|
|
model wifi_networks {
|
|
id String @id
|
|
ssid String
|
|
description String?
|
|
ipRange String
|
|
latitude Float?
|
|
longitude Float?
|
|
radius Int @default(50)
|
|
isActive Boolean @default(true)
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime
|
|
schedules schedules[]
|
|
}
|
|
|
|
enum notifications_type {
|
|
ATTENDANCE_REMINDER
|
|
ABSENCE_ALERT
|
|
LEAVE_APPROVED
|
|
LEAVE_REJECTED
|
|
SYSTEM
|
|
}
|
|
|
|
enum attendances_status {
|
|
PRESENT
|
|
LATE
|
|
EXCUSED
|
|
SICK
|
|
ABSENT
|
|
}
|
|
|
|
enum users_role {
|
|
ADMIN
|
|
STUDENT
|
|
TEACHER
|
|
}
|
|
|
|
enum leave_requests_type {
|
|
SICK
|
|
EXCUSED
|
|
OTHER
|
|
}
|
|
|
|
enum schedules_dayOfWeek {
|
|
MONDAY
|
|
TUESDAY
|
|
WEDNESDAY
|
|
THURSDAY
|
|
FRIDAY
|
|
SATURDAY
|
|
SUNDAY
|
|
}
|
|
|
|
enum leave_requests_status {
|
|
PENDING
|
|
APPROVED
|
|
REJECTED
|
|
}
|