mirror of
https://github.com/margrop/wrong-notebook.git
synced 2026-12-02 09:14:19 +08:00
101 lines
2.8 KiB
Plaintext
101 lines
2.8 KiB
Plaintext
// 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"
|
|
binaryTargets = ["native", "linux-musl-openssl-3.0.x"]
|
|
}
|
|
|
|
datasource db {
|
|
provider = "sqlite"
|
|
url = env("DATABASE_URL")
|
|
}
|
|
|
|
model User {
|
|
id String @id @default(cuid())
|
|
email String @unique
|
|
password String
|
|
name String?
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
educationStage String? // primary, junior_high, senior_high, university
|
|
enrollmentYear Int?
|
|
|
|
role String @default("user") // "admin" or "user"
|
|
isActive Boolean @default(true) // 用户是否启用
|
|
|
|
errorItems ErrorItem[]
|
|
subjects Subject[]
|
|
practiceRecords PracticeRecord[]
|
|
}
|
|
|
|
model Subject {
|
|
id String @id @default(cuid())
|
|
name String
|
|
userId String
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
|
|
errorItems ErrorItem[]
|
|
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
@@unique([name, userId])
|
|
}
|
|
|
|
model ErrorItem {
|
|
id String @id @default(cuid())
|
|
userId String
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
subjectId String?
|
|
subject Subject? @relation(fields: [subjectId], references: [id], onDelete: Cascade)
|
|
|
|
originalImageUrl String
|
|
ocrText String?
|
|
|
|
// AI Analysis
|
|
questionText String? // Parsed question
|
|
answerText String? // AI provided answer
|
|
analysis String? // AI analysis/explanation
|
|
knowledgePoints String? // JSON string or comma-separated tags
|
|
|
|
// User Metadata
|
|
source String? // e.g. "Midterm Exam"
|
|
errorType String? // e.g. "Calculation", "Concept"
|
|
userNotes String?
|
|
|
|
masteryLevel Int @default(0) // 0: New, 1: Reviewing, 2: Mastered
|
|
gradeSemester String? // e.g. "Junior High Grade 2, 1st Semester"
|
|
paperLevel String? // e.g. "A", "B", "Other"
|
|
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
reviewSchedules ReviewSchedule[]
|
|
}
|
|
|
|
model ReviewSchedule {
|
|
id String @id @default(cuid())
|
|
errorItemId String
|
|
errorItem ErrorItem @relation(fields: [errorItemId], references: [id], onDelete: Cascade)
|
|
|
|
scheduledFor DateTime
|
|
completedAt DateTime?
|
|
isCorrect Boolean? // Result of the review
|
|
|
|
createdAt DateTime @default(now())
|
|
}
|
|
|
|
model PracticeRecord {
|
|
id String @id @default(cuid())
|
|
userId String
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
|
|
subject String? // e.g. "Math", "Physics"
|
|
difficulty String? // "easy", "medium", "hard", "harder"
|
|
isCorrect Boolean?
|
|
|
|
createdAt DateTime @default(now())
|
|
}
|