226 lines
5.5 KiB
Plaintext
226 lines
5.5 KiB
Plaintext
generator client {
|
|
provider = "prisma-client-js"
|
|
}
|
|
|
|
datasource db {
|
|
provider = "postgresql"
|
|
url = env("DATABASE_URL")
|
|
}
|
|
|
|
// ─── Enums ───────────────────────────────────────────────────────────────────
|
|
|
|
enum Role {
|
|
ADMIN
|
|
LEARNER
|
|
}
|
|
|
|
enum CourseCategory {
|
|
GOVERNANCE
|
|
CYBER
|
|
OWLCUB
|
|
OTHER
|
|
}
|
|
|
|
enum CourseLevel {
|
|
BEGINNER
|
|
INTERMEDIATE
|
|
ADVANCED
|
|
}
|
|
|
|
enum LessonType {
|
|
VIDEO
|
|
TEXT
|
|
}
|
|
|
|
// ─── NextAuth Models ──────────────────────────────────────────────────────────
|
|
|
|
model User {
|
|
id String @id @default(cuid())
|
|
email String @unique
|
|
name String?
|
|
image String?
|
|
emailVerified DateTime?
|
|
locale String @default("fr")
|
|
role Role @default(LEARNER)
|
|
createdAt DateTime @default(now())
|
|
|
|
accounts Account[]
|
|
sessions Session[]
|
|
enrollments Enrollment[]
|
|
lessonProgress LessonProgress[]
|
|
quizAttempts QuizAttempt[]
|
|
certificates Certificate[]
|
|
}
|
|
|
|
model Account {
|
|
id String @id @default(cuid())
|
|
userId String
|
|
type String
|
|
provider String
|
|
providerAccountId String
|
|
refresh_token String? @db.Text
|
|
access_token String? @db.Text
|
|
expires_at Int?
|
|
token_type String?
|
|
scope String?
|
|
id_token String? @db.Text
|
|
session_state String?
|
|
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
|
|
@@unique([provider, providerAccountId])
|
|
}
|
|
|
|
model Session {
|
|
id String @id @default(cuid())
|
|
sessionToken String @unique
|
|
userId String
|
|
expires DateTime
|
|
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
}
|
|
|
|
model VerificationToken {
|
|
identifier String
|
|
token String @unique
|
|
expires DateTime
|
|
|
|
@@unique([identifier, token])
|
|
}
|
|
|
|
// ─── Academy Models ───────────────────────────────────────────────────────────
|
|
|
|
model Course {
|
|
id String @id @default(cuid())
|
|
slug String @unique
|
|
category CourseCategory @default(OTHER)
|
|
level CourseLevel @default(BEGINNER)
|
|
thumbnailUrl String?
|
|
published Boolean @default(false)
|
|
order Int @default(0)
|
|
createdAt DateTime @default(now())
|
|
|
|
titleFr String
|
|
titleEn String
|
|
titleEs String
|
|
descFr String @db.Text
|
|
descEn String @db.Text
|
|
descEs String @db.Text
|
|
|
|
modules Module[]
|
|
enrollments Enrollment[]
|
|
certificates Certificate[]
|
|
}
|
|
|
|
model Module {
|
|
id String @id @default(cuid())
|
|
courseId String
|
|
order Int @default(0)
|
|
|
|
titleFr String
|
|
titleEn String
|
|
titleEs String
|
|
|
|
course Course @relation(fields: [courseId], references: [id], onDelete: Cascade)
|
|
lessons Lesson[]
|
|
quiz Quiz?
|
|
}
|
|
|
|
model Lesson {
|
|
id String @id @default(cuid())
|
|
moduleId String
|
|
order Int @default(0)
|
|
type LessonType @default(TEXT)
|
|
videoUrl String?
|
|
duration Int?
|
|
|
|
titleFr String
|
|
titleEn String
|
|
titleEs String
|
|
contentFr String? @db.Text
|
|
contentEn String? @db.Text
|
|
contentEs String? @db.Text
|
|
|
|
module Module @relation(fields: [moduleId], references: [id], onDelete: Cascade)
|
|
lessonProgress LessonProgress[]
|
|
}
|
|
|
|
model Quiz {
|
|
id String @id @default(cuid())
|
|
moduleId String @unique
|
|
passMark Int @default(80)
|
|
|
|
module Module @relation(fields: [moduleId], references: [id], onDelete: Cascade)
|
|
questions Question[]
|
|
attempts QuizAttempt[]
|
|
}
|
|
|
|
model Question {
|
|
id String @id @default(cuid())
|
|
quizId String
|
|
order Int @default(0)
|
|
|
|
textFr String
|
|
textEn String
|
|
textEs String
|
|
|
|
optionsFr String[]
|
|
optionsEn String[]
|
|
optionsEs String[]
|
|
correctIndex Int
|
|
|
|
quiz Quiz @relation(fields: [quizId], references: [id], onDelete: Cascade)
|
|
}
|
|
|
|
model Enrollment {
|
|
id String @id @default(cuid())
|
|
userId String
|
|
courseId String
|
|
enrolledAt DateTime @default(now())
|
|
completedAt DateTime?
|
|
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
course Course @relation(fields: [courseId], references: [id], onDelete: Cascade)
|
|
|
|
@@unique([userId, courseId])
|
|
}
|
|
|
|
model LessonProgress {
|
|
id String @id @default(cuid())
|
|
userId String
|
|
lessonId String
|
|
completedAt DateTime @default(now())
|
|
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
lesson Lesson @relation(fields: [lessonId], references: [id], onDelete: Cascade)
|
|
|
|
@@unique([userId, lessonId])
|
|
}
|
|
|
|
model QuizAttempt {
|
|
id String @id @default(cuid())
|
|
userId String
|
|
quizId String
|
|
score Int
|
|
passed Boolean
|
|
answers Int[]
|
|
completedAt DateTime @default(now())
|
|
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
quiz Quiz @relation(fields: [quizId], references: [id], onDelete: Cascade)
|
|
}
|
|
|
|
model Certificate {
|
|
id String @id @default(cuid())
|
|
userId String
|
|
courseId String
|
|
issuedAt DateTime @default(now())
|
|
pdfUrl String?
|
|
isPaid Boolean @default(false)
|
|
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
course Course @relation(fields: [courseId], references: [id], onDelete: Cascade)
|
|
|
|
@@unique([userId, courseId])
|
|
}
|