35f27a6eb7
Made-with: Cursor
122 lines
3.4 KiB
Plaintext
122 lines
3.4 KiB
Plaintext
generator client {
|
|
provider = "prisma-client-js"
|
|
binaryTargets = ["native", "linux-musl-openssl-3.0.x", "linux-musl-arm64-openssl-3.0.x"]
|
|
}
|
|
|
|
datasource db {
|
|
provider = "postgresql"
|
|
url = env("DATABASE_URL")
|
|
}
|
|
|
|
enum Role {
|
|
TUTOR
|
|
STUDENT
|
|
}
|
|
|
|
model User {
|
|
id Int @id @default(autoincrement())
|
|
username String @unique
|
|
passwordHash String
|
|
role Role
|
|
displayName String?
|
|
|
|
tutoringAssignments TutorAssignment[] @relation("TutorInAssignment")
|
|
studentAssignment TutorAssignment? @relation("StudentInAssignment")
|
|
|
|
questions Question[]
|
|
chatMessages ChatMessage[]
|
|
textbooks Textbook[]
|
|
testsInScope Test[] @relation("TestStudentScope")
|
|
testsAuthored Test[] @relation("TestAuthor")
|
|
testResults TestResult[]
|
|
reports Report[]
|
|
hallPhotos HallPhoto[]
|
|
}
|
|
|
|
model TutorAssignment {
|
|
tutorId Int
|
|
studentId Int @unique
|
|
tutor User @relation("TutorInAssignment", fields: [tutorId], references: [id], onDelete: Cascade)
|
|
student User @relation("StudentInAssignment", fields: [studentId], references: [id], onDelete: Cascade)
|
|
|
|
@@id([tutorId, studentId])
|
|
}
|
|
|
|
model Setting {
|
|
key String @id
|
|
value String
|
|
}
|
|
|
|
model ChatMessage {
|
|
id Int @id @default(autoincrement())
|
|
studentId Int
|
|
student User @relation(fields: [studentId], references: [id], onDelete: Cascade)
|
|
role String
|
|
content String
|
|
createdAt DateTime @default(now())
|
|
}
|
|
|
|
model Question {
|
|
id Int @id @default(autoincrement())
|
|
studentId Int
|
|
student User @relation(fields: [studentId], references: [id], onDelete: Cascade)
|
|
text String
|
|
answer String?
|
|
date String
|
|
createdAt DateTime @default(now())
|
|
}
|
|
|
|
model Textbook {
|
|
id Int @id @default(autoincrement())
|
|
studentId Int
|
|
student User @relation(fields: [studentId], references: [id], onDelete: Cascade)
|
|
topic String
|
|
content String
|
|
createdAt DateTime @default(now())
|
|
}
|
|
|
|
model Test {
|
|
id Int @id @default(autoincrement())
|
|
/// Контекст пары наставник–ученик (id назначенного ученика); общие тесты для обоих
|
|
studentId Int
|
|
student User @relation("TestStudentScope", fields: [studentId], references: [id], onDelete: Cascade)
|
|
authorId Int
|
|
author User @relation("TestAuthor", fields: [authorId], references: [id], onDelete: Cascade)
|
|
topic String
|
|
questions String
|
|
createdAt DateTime @default(now())
|
|
results TestResult[]
|
|
}
|
|
|
|
model TestResult {
|
|
id Int @id @default(autoincrement())
|
|
testId Int
|
|
test Test @relation(fields: [testId], references: [id], onDelete: Cascade)
|
|
studentId Int
|
|
student User @relation(fields: [studentId], references: [id], onDelete: Cascade)
|
|
answers String
|
|
score Int
|
|
total Int
|
|
createdAt DateTime @default(now())
|
|
}
|
|
|
|
model Report {
|
|
id Int @id @default(autoincrement())
|
|
studentId Int
|
|
student User @relation(fields: [studentId], references: [id], onDelete: Cascade)
|
|
date String
|
|
content String
|
|
createdAt DateTime @default(now())
|
|
}
|
|
|
|
model HallPhoto {
|
|
id Int @id @default(autoincrement())
|
|
studentId Int
|
|
student User @relation(fields: [studentId], references: [id], onDelete: Cascade)
|
|
date String
|
|
fileName String
|
|
originalName String @default("")
|
|
mimeType String
|
|
createdAt DateTime @default(now())
|
|
}
|