2026-01-13 01:59:40 +00:00
|
|
|
// This is your Prisma schema file,
|
|
|
|
|
// learn more about it in the docs: https://pris.ly/d/prisma-schema
|
|
|
|
|
|
|
|
|
|
generator client {
|
|
|
|
|
provider = "prisma-client-js"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
datasource db {
|
|
|
|
|
provider = "sqlite"
|
|
|
|
|
url = "file:./dev.db"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
model Course {
|
|
|
|
|
id String @id @default(uuid())
|
|
|
|
|
title String
|
|
|
|
|
description String
|
|
|
|
|
category String // ML_BASICS, DEEP_LEARNING, NLP, LLM, AI_TOOLS
|
|
|
|
|
difficulty String // BEGINNER, INTERMEDIATE, ADVANCED
|
|
|
|
|
estimatedHours Int
|
|
|
|
|
createdAt DateTime @default(now())
|
|
|
|
|
updatedAt DateTime @updatedAt
|
|
|
|
|
chapters Chapter[]
|
|
|
|
|
pathItems PathItem[]
|
2026-01-14 11:30:15 +00:00
|
|
|
userProgress UserProgress[]
|
2026-01-13 01:59:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
model Chapter {
|
|
|
|
|
id String @id @default(uuid())
|
|
|
|
|
courseId String
|
|
|
|
|
title String
|
|
|
|
|
order Int
|
|
|
|
|
content String // Markdown content
|
|
|
|
|
createdAt DateTime @default(now())
|
|
|
|
|
updatedAt DateTime @updatedAt
|
|
|
|
|
course Course @relation(fields: [courseId], references: [id], onDelete: Cascade)
|
|
|
|
|
pathItems PathItem[]
|
2026-01-14 11:30:15 +00:00
|
|
|
userProgress UserProgress[]
|
2026-01-13 01:59:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
model LearningPath {
|
|
|
|
|
id String @id @default(uuid())
|
|
|
|
|
name String
|
|
|
|
|
description String
|
|
|
|
|
targetAudience String
|
|
|
|
|
createdAt DateTime @default(now())
|
|
|
|
|
updatedAt DateTime @updatedAt
|
|
|
|
|
pathItems PathItem[]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
model PathItem {
|
|
|
|
|
id String @id @default(uuid())
|
|
|
|
|
pathId String
|
|
|
|
|
courseId String
|
|
|
|
|
chapterId String?
|
|
|
|
|
order Int
|
|
|
|
|
type String // 'course' or 'chapter'
|
|
|
|
|
createdAt DateTime @default(now())
|
|
|
|
|
updatedAt DateTime @updatedAt
|
|
|
|
|
path LearningPath @relation(fields: [pathId], references: [id], onDelete: Cascade)
|
|
|
|
|
course Course @relation(fields: [courseId], references: [id], onDelete: Cascade)
|
|
|
|
|
chapter Chapter? @relation(fields: [chapterId], references: [id], onDelete: Cascade)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
model UserProgress {
|
|
|
|
|
id String @id @default(uuid())
|
|
|
|
|
userId String @default("default") // MVP阶段使用默认用户
|
|
|
|
|
courseId String
|
|
|
|
|
chapterId String?
|
|
|
|
|
completed Boolean @default(false)
|
|
|
|
|
lastAccessed DateTime @default(now())
|
|
|
|
|
createdAt DateTime @default(now())
|
|
|
|
|
updatedAt DateTime @updatedAt
|
|
|
|
|
|
2026-01-14 11:30:15 +00:00
|
|
|
course Course @relation(fields: [courseId], references: [id], onDelete: Cascade)
|
|
|
|
|
chapter Chapter? @relation(fields: [chapterId], references: [id], onDelete: Cascade)
|
|
|
|
|
|
2026-01-13 01:59:40 +00:00
|
|
|
@@unique([userId, courseId, chapterId])
|
|
|
|
|
}
|