119 lines
3.5 KiB
Plaintext
119 lines
3.5 KiB
Plaintext
// Training & Certification Domain
|
|
// Contains training programs, certifications, and farmer development
|
|
|
|
// Training-specific Enums
|
|
enum TrainingStatus {
|
|
ENROLLED
|
|
IN_PROGRESS
|
|
COMPLETED
|
|
DROPPED
|
|
}
|
|
|
|
enum CertificationStatus {
|
|
PENDING
|
|
APPROVED
|
|
REJECTED
|
|
EXPIRED
|
|
}
|
|
|
|
// Training Models
|
|
model Training {
|
|
id String @id @default(cuid())
|
|
title String
|
|
description String?
|
|
content String?
|
|
category String
|
|
duration Int? // in minutes
|
|
level String? // beginner, intermediate, advanced
|
|
prerequisites String?
|
|
maxParticipants Int? // Maximum number of participants
|
|
createdBy String? // Admin who created the training
|
|
isActive Boolean @default(true)
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
// Relations
|
|
farmerTrainings FarmerTraining[]
|
|
|
|
@@index([category])
|
|
@@index([level])
|
|
@@index([isActive])
|
|
@@index([duration])
|
|
@@index([createdBy])
|
|
@@map("trainings")
|
|
}
|
|
|
|
model FarmerTraining {
|
|
id String @id @default(cuid())
|
|
farmerId String
|
|
trainingId String
|
|
status TrainingStatus @default(ENROLLED)
|
|
progress Int @default(0) // percentage
|
|
score Float?
|
|
completedAt DateTime?
|
|
assignedBy String? // Admin who assigned the farmer to training
|
|
assignedAt DateTime? // When the assignment was made
|
|
assignmentReason String? // Reason for assignment
|
|
deadline DateTime? // Expected completion deadline
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
// Relations
|
|
farmer Farmer @relation(fields: [farmerId], references: [id], onDelete: Cascade)
|
|
training Training @relation(fields: [trainingId], references: [id], onDelete: Cascade)
|
|
|
|
@@unique([farmerId, trainingId])
|
|
@@index([farmerId])
|
|
@@index([trainingId])
|
|
@@index([status])
|
|
@@index([completedAt])
|
|
@@index([progress])
|
|
@@index([assignedBy])
|
|
@@index([assignedAt])
|
|
@@index([deadline])
|
|
@@map("farmer_trainings")
|
|
}
|
|
|
|
model Certification {
|
|
id String @id @default(cuid())
|
|
name String
|
|
description String?
|
|
validityPeriod Int? // in months
|
|
requirements String?
|
|
isActive Boolean @default(true)
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
// Relations
|
|
farmerCertifications FarmerCertification[]
|
|
|
|
@@index([name])
|
|
@@index([isActive])
|
|
@@index([validityPeriod])
|
|
@@map("certifications")
|
|
}
|
|
|
|
model FarmerCertification {
|
|
id String @id @default(cuid())
|
|
farmerId String
|
|
certificationId String
|
|
status CertificationStatus @default(PENDING)
|
|
issuedDate DateTime?
|
|
expiryDate DateTime?
|
|
certificateNumber String?
|
|
notes String?
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
// Relations
|
|
farmer Farmer @relation(fields: [farmerId], references: [id], onDelete: Cascade)
|
|
certification Certification @relation(fields: [certificationId], references: [id], onDelete: Cascade)
|
|
|
|
@@unique([farmerId, certificationId])
|
|
@@index([farmerId])
|
|
@@index([certificationId])
|
|
@@index([status])
|
|
@@index([expiryDate])
|
|
@@index([issuedDate])
|
|
@@map("farmer_certifications")
|
|
} |