2025-11-11 11:41:08 +09:00
|
|
|
// This is your Prisma schema file,
|
|
|
|
|
// learn more about it in the docs: https://pris.ly/d/prisma-schema
|
|
|
|
|
|
|
|
|
|
// Looking for ways to speed up your queries, or scale easily with your serverless or edge functions?
|
|
|
|
|
// Try Prisma Accelerate: https://pris.ly/cli/accelerate-init
|
|
|
|
|
|
2025-11-11 20:01:37 +09:00
|
|
|
// This is your Prisma schema file,
|
|
|
|
|
// learn more about it in the docs: https://pris.ly/d/prisma-schema
|
|
|
|
|
|
2025-11-11 11:41:08 +09:00
|
|
|
generator client {
|
|
|
|
|
provider = "prisma-client"
|
|
|
|
|
output = "../lib/generated/prisma"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
datasource db {
|
2025-11-11 20:01:37 +09:00
|
|
|
provider = "sqlite"
|
|
|
|
|
url = "file:./prisma/dev.db"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 사용자 권한 Enum
|
|
|
|
|
enum UserRole {
|
|
|
|
|
STUDENT // 학습자
|
|
|
|
|
INSTRUCTOR // 강사
|
|
|
|
|
ADMIN // 관리자
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// User 모델
|
|
|
|
|
model User {
|
|
|
|
|
id String @id @default(cuid())
|
|
|
|
|
email String @unique
|
|
|
|
|
name String?
|
|
|
|
|
password String
|
|
|
|
|
phone String?
|
|
|
|
|
gender String?
|
|
|
|
|
birthYear Int?
|
|
|
|
|
birthMonth Int?
|
|
|
|
|
birthDay Int?
|
|
|
|
|
role UserRole @default(STUDENT) // 권한 (기본값: 학습자)
|
|
|
|
|
isActive Boolean @default(true) // 계정 활성화 여부 (true: 활성화, false: 비활성화)
|
|
|
|
|
createdAt DateTime @default(now())
|
|
|
|
|
updatedAt DateTime @updatedAt
|
|
|
|
|
registeredLectures Lecture[] @relation("Registrant") // 등록한 강좌 목록
|
|
|
|
|
enrolledLectures UserLecture[] // 수강 중인 강좌 목록
|
|
|
|
|
|
|
|
|
|
@@map("users")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 교육 과정 관리
|
|
|
|
|
model Curriculum {
|
|
|
|
|
id String @id @default(cuid())
|
|
|
|
|
title String // 과정 제목
|
|
|
|
|
thumbnailImage String? // 썸네일 이미지 경로
|
|
|
|
|
instructorId String // 강사 ID (User와의 관계)
|
|
|
|
|
createdAt DateTime @default(now())
|
|
|
|
|
updatedAt DateTime @updatedAt
|
|
|
|
|
lectures Lecture[] // 강좌 목록 (1:N 관계)
|
|
|
|
|
|
|
|
|
|
@@map("curriculums")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 강좌 관리
|
|
|
|
|
model Lecture {
|
|
|
|
|
id String @id @default(cuid())
|
|
|
|
|
title String // 강좌명
|
|
|
|
|
thumbnailImage String? // 썸네일 이미지 경로
|
|
|
|
|
attachmentFile String? // 첨부 파일 경로
|
|
|
|
|
evaluationQuestionCount Int @default(0) // 학습 평가 문제 수
|
|
|
|
|
curriculumId String // 교육 과정 ID (Curriculum과의 관계)
|
|
|
|
|
registrantId String // 등록자 ID (User와의 관계)
|
|
|
|
|
registeredAt DateTime @default(now()) // 등록일
|
|
|
|
|
createdAt DateTime @default(now())
|
|
|
|
|
updatedAt DateTime @updatedAt
|
|
|
|
|
|
|
|
|
|
curriculum Curriculum @relation(fields: [curriculumId], references: [id], onDelete: Cascade)
|
|
|
|
|
registrant User @relation("Registrant", fields: [registrantId], references: [id])
|
|
|
|
|
enrolledUsers UserLecture[] // 수강 중인 사용자 목록
|
|
|
|
|
|
|
|
|
|
@@map("lectures")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 사용자-강좌 수강 관계 (다대다 관계)
|
|
|
|
|
model UserLecture {
|
|
|
|
|
id String @id @default(cuid())
|
|
|
|
|
userId String // 사용자 ID
|
|
|
|
|
lectureId String // 강좌 ID
|
|
|
|
|
enrolledAt DateTime @default(now()) // 수강 시작일
|
|
|
|
|
completedAt DateTime? // 수강 완료일
|
|
|
|
|
isCompleted Boolean @default(false) // 수강 완료 여부
|
|
|
|
|
progress Int @default(0) // 수강 진행률 (0-100)
|
|
|
|
|
score Int? // 평가 점수
|
|
|
|
|
createdAt DateTime @default(now())
|
|
|
|
|
updatedAt DateTime @updatedAt
|
|
|
|
|
|
|
|
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
|
|
|
lecture Lecture @relation(fields: [lectureId], references: [id], onDelete: Cascade)
|
|
|
|
|
|
|
|
|
|
@@unique([userId, lectureId]) // 한 사용자는 같은 강좌를 중복 수강할 수 없음
|
|
|
|
|
@@map("user_lectures")
|
2025-11-11 11:41:08 +09:00
|
|
|
}
|