| datasource db { |
| provider = "postgresql" |
| url = env("DATABASE_URL") |
| extensions = [vector] |
| } |
|
|
| generator client { |
| provider = "prisma-client-py" |
| recursive_type_depth = 5 |
| previewFeatures = ["postgresqlExtensions"] |
| } |
|
|
| enum Role { |
| STUDENT |
| TEACHER |
| ADMIN |
| } |
|
|
| enum LeaveStatus { |
| PENDING |
| APPROVED |
| REJECTED |
| } |
|
|
| enum DeviceChangeStatus { |
| PENDING |
| APPROVED |
| REJECTED |
| } |
|
|
| model User { |
| id String @id @default(uuid()) |
| email String @unique |
| hashedPassword String @map("hashed_password") |
| role Role @default(STUDENT) |
| isActive Boolean @default(true) @map("is_active") |
| createdAt DateTime @default(now()) @map("created_at") |
| updatedAt DateTime @updatedAt @map("updated_at") |
|
|
| student Student? |
| teacher Teacher? |
|
|
| @@map("users") |
| } |
|
|
| model Student { |
| id String @id @default(uuid()) |
| userId String @unique @map("user_id") |
| enrollmentNumber String @unique @map("enrollment_number") |
| firstName String? @map("first_name") |
| lastName String? @map("last_name") |
| phone String? @map("phone") |
| gender String? @map("gender") |
| dateOfBirth DateTime? @map("date_of_birth") |
| semester Int? @map("semester") |
| batch String? @map("batch") |
| departmentId String? @map("department_id") |
| deviceUuid String? @map("device_uuid") |
| fcmToken String? @map("fcm_token") |
| faceEmbedding Unsupported("vector(128)")? @map("face_embedding") |
| currentStreak Int @default(0) @map("current_streak") |
| highestStreak Int @default(0) @map("highest_streak") |
| createdAt DateTime @default(now()) @map("created_at") |
| updatedAt DateTime @updatedAt @map("updated_at") |
|
|
| user User @relation(fields: [userId], references: [id], onDelete: Cascade) |
| department Department? @relation(fields: [departmentId], references: [id]) |
| attendance Attendance[] |
| enrollments Enrollment[] |
| leaveRequests LeaveRequest[] |
| deviceChangeRequests DeviceChangeRequest[] |
|
|
| @@map("students") |
| } |
|
|
| model Teacher { |
| id String @id @default(uuid()) |
| userId String @unique @map("user_id") |
| firstName String @map("first_name") |
| lastName String @map("last_name") |
| employeeId String @unique @map("employee_id") |
| phone String? @map("phone") |
| qualification String? @map("qualification") |
| specialization String? @map("specialization") |
| experienceYears Int? @map("experience_years") |
| joiningDate DateTime? @map("joining_date") |
| departmentId String @map("department_id") |
| designationId String @map("designation_id") |
| createdAt DateTime @default(now()) @map("created_at") |
| updatedAt DateTime @updatedAt @map("updated_at") |
|
|
| user User @relation(fields: [userId], references: [id], onDelete: Cascade) |
| department Department @relation(fields: [departmentId], references: [id]) |
| designation Designation @relation(fields: [designationId], references: [id]) |
| classes AcademicClass[] |
|
|
| @@map("teachers") |
| } |
|
|
| model AcademicClass { |
| id String @id @default(uuid()) |
| name String |
| subjectId String @map("subject_id") |
| classroomId String? @map("classroom_id") |
| teacherId String @map("teacher_id") |
| semester Int? @map("semester") |
| batch String? @map("batch") |
| maxStudents Int? @map("max_students") |
| createdAt DateTime @default(now()) @map("created_at") |
| updatedAt DateTime @updatedAt @map("updated_at") |
|
|
| teacher Teacher @relation(fields: [teacherId], references: [id]) |
| subject Subject @relation(fields: [subjectId], references: [id]) |
| classroom Classroom? @relation(fields: [classroomId], references: [id]) |
| sessions Session[] |
| geofence Geofence? |
| enrollments Enrollment[] |
|
|
| @@map("classes") |
| } |
|
|
| model Session { |
| id String @id @default(uuid()) |
| academicClassId String @map("class_id") |
| startTime DateTime @map("start_time") |
| endTime DateTime @map("end_time") |
| isActive Boolean @default(true) @map("is_active") |
| createdAt DateTime @default(now()) @map("created_at") |
| updatedAt DateTime @updatedAt @map("updated_at") |
|
|
| academicClass AcademicClass @relation(fields: [academicClassId], references: [id]) |
| attendance Attendance[] |
|
|
| @@map("sessions") |
| } |
|
|
| model Geofence { |
| id String @id @default(uuid()) |
| academicClassId String @unique @map("class_id") |
| latitude Float |
| longitude Float |
| radiusMeters Float @map("radius_meters") |
| createdAt DateTime @default(now()) @map("created_at") |
| updatedAt DateTime @updatedAt @map("updated_at") |
|
|
| academicClass AcademicClass @relation(fields: [academicClassId], references: [id]) |
|
|
| @@map("geofences") |
| } |
|
|
| model Attendance { |
| id String @id @default(uuid()) |
| studentId String @map("student_id") |
| sessionId String @map("session_id") |
| status String |
| faceScore Float @map("face_score") |
| livenessScore Float @map("liveness_score") |
| backgroundScore Float @map("background_score") |
| finalAiScore Float @map("final_ai_score") |
| gpsLatitude Float @map("gps_latitude") |
| gpsLongitude Float @map("gps_longitude") |
| remarks String? |
| studentNote String? @map("student_note") |
| createdAt DateTime @default(now()) @map("created_at") |
| updatedAt DateTime @updatedAt @map("updated_at") |
|
|
| student Student @relation(fields: [studentId], references: [id]) |
| session Session @relation(fields: [sessionId], references: [id]) |
|
|
| @@unique([studentId, sessionId]) |
| @@map("attendance") |
| } |
|
|
| model Enrollment { |
| id String @id @default(uuid()) |
| studentId String @map("student_id") |
| academicClassId String @map("academic_class_id") |
| enrolledAt DateTime @default(now()) @map("enrolled_at") |
|
|
| student Student @relation(fields: [studentId], references: [id], onDelete: Cascade) |
| academicClass AcademicClass @relation(fields: [academicClassId], references: [id], onDelete: Cascade) |
|
|
| @@unique([studentId, academicClassId]) |
| @@map("enrollments") |
| } |
|
|
| model Department { |
| id String @id @default(uuid()) |
| name String @unique |
| code String @unique |
| head String? |
| description String? |
| createdAt DateTime @default(now()) @map("created_at") |
| updatedAt DateTime @updatedAt @map("updated_at") |
|
|
| teachers Teacher[] |
| students Student[] |
|
|
| @@map("departments") |
| } |
|
|
| model Subject { |
| id String @id @default(uuid()) |
| name String @unique |
| code String @unique |
| description String? |
| createdAt DateTime @default(now()) @map("created_at") |
| updatedAt DateTime @updatedAt @map("updated_at") |
|
|
| classes AcademicClass[] |
|
|
| @@map("subjects") |
| } |
|
|
| model Classroom { |
| id String @id @default(uuid()) |
| name String @unique |
| building String? |
| capacity Int? |
| createdAt DateTime @default(now()) @map("created_at") |
| updatedAt DateTime @updatedAt @map("updated_at") |
|
|
| classes AcademicClass[] |
|
|
| @@map("classrooms") |
| } |
|
|
| model Designation { |
| id String @id @default(uuid()) |
| name String @unique |
| code String @unique |
| description String? |
| createdAt DateTime @default(now()) @map("created_at") |
| updatedAt DateTime @updatedAt @map("updated_at") |
|
|
| teachers Teacher[] |
|
|
| @@map("designations") |
| } |
|
|
| model LeaveRequest { |
| id String @id @default(uuid()) |
| studentId String @map("student_id") |
| startDate DateTime @map("start_date") |
| endDate DateTime @map("end_date") |
| reason String |
| documentUrl String? @map("document_url") |
| status LeaveStatus @default(PENDING) |
| approvedBy String? @map("approved_by") |
| approverNote String? @map("approver_note") |
| createdAt DateTime @default(now()) @map("created_at") |
| updatedAt DateTime @updatedAt @map("updated_at") |
|
|
| student Student @relation(fields: [studentId], references: [id], onDelete: Cascade) |
|
|
| @@map("leave_requests") |
| } |
|
|
| model AuditLog { |
| id String @id @default(uuid()) |
| timestamp DateTime @default(now()) |
| eventType String @map("event_type") |
| severity String |
| actor String |
| target String |
| description String |
| ipAddress String? @map("ip_address") |
| metadata Json? |
|
|
| @@map("audit_logs") |
| } |
|
|
| model DeviceChangeRequest { |
| id String @id @default(uuid()) |
| studentId String @map("student_id") |
| status DeviceChangeStatus @default(PENDING) |
| reason String? |
| newDeviceUuid String @map("new_device_uuid") |
| approvedBy String? @map("approved_by") |
| createdAt DateTime @default(now()) @map("created_at") |
| updatedAt DateTime @updatedAt @map("updated_at") |
|
|
| student Student @relation(fields: [studentId], references: [id], onDelete: Cascade) |
|
|
| @@map("device_change_requests") |
| } |
|
|
| model SystemConfiguration { |
| id String @id @default(uuid()) |
| isFaceRecognitionEnabled Boolean @default(true) @map("is_face_recognition_enabled") |
| isGpsVerificationEnabled Boolean @default(true) @map("is_gps_verification_enabled") |
| isAiBackgroundValidationEnabled Boolean @default(true) @map("is_ai_background_validation_enabled") |
| updatedAt DateTime @updatedAt @map("updated_at") |
|
|
| @@map("system_configurations") |
| } |
|
|