generator client { provider = "prisma-client-js" } datasource db { provider = "mysql" url = env("DATABASE_URL") } model User { id String @id createdAt DateTime @default(now()) updatedAt DateTime @updatedAt email String @unique @db.VarChar(255) username String @unique @db.VarChar(255) password String refreshToken String? @unique @db.VarChar(255) isDarkMode Boolean @default(true) books Book[] reviews Review[] ratings Rating[] } enum WorkingProgressStatus { inProgress frozen complete } model Book { id String @id createdAt DateTime @default(now()) updatedAt DateTime @updatedAt title String @db.VarChar(255) description String @db.MediumText progressStatus WorkingProgressStatus @default(inProgress) author User @relation(fields: [authorId], references: [id]) authorId String wordsTotal Int @default(0) chapters BookChapter[] reviews Review[] ratings Rating[] } model BookChapter { id String @id createdAt DateTime @default(now()) updatedAt DateTime @updatedAt title String @db.VarChar(255) foreword String @db.MediumText footnote String @db.MediumText wordsTotal Int @default(0) book Book @relation(fields: [bookId], references: [id]) bookId String @db.VarChar(255) reviews Review[] ratings Rating[] } model Review { id String @id createdAt DateTime @default(now()) updatedAt DateTime @updatedAt text String @db.MediumText user User @relation(fields: [userId], references: [id]) userId String @db.VarChar(255) bookChapter BookChapter? @relation(fields: [bookChapterId], references: [id]) bookChapterId String? @db.VarChar(255) book Book? @relation(fields: [bookId], references: [id]) bookId String? } enum RatingType { up down } model Rating { id String @id createdAt DateTime @default(now()) updatedAt DateTime @updatedAt type RatingType user User @relation(fields: [userId], references: [id]) userId String @db.VarChar(255) bookChapter BookChapter? @relation(fields: [bookChapterId], references: [id]) bookChapterId String? @db.VarChar(255) book Book? @relation(fields: [bookId], references: [id]) bookId String? }