Files
wfh/prisma/schema.prisma
T
jason a9df9c0cf4
Build and Push Docker Image / build (push) Successful in 2m26s
Harden API, data layer, and autosave; add validation, pagination, migrations
- Enforce task ownership on PATCH/DELETE /api/tasks (was: any signed-in
  user could edit or delete anyone's tasks)
- Validate all API request bodies with zod; escape user content and
  restrict links to http(s) in the Drive export; block reverting a
  SUBMITTED report
- Add @@unique([userId, date]) on Report with upsert to eliminate the
  duplicate-daily-report race; switch startup from
  `prisma db push --accept-data-loss` to `prisma migrate deploy` with
  automatic baselining of existing databases (dedup migration merges
  any pre-existing duplicates)
- Autosave: re-queue and retry failed task saves with a visible
  saving/error indicator instead of silently dropping edits
- Paginate and filter GET /api/reports (?date, ?mine, ?q, ?take,
  ?cursor); report form fetches only today's report, admin dashboard
  uses server-side search + Load more
- Type the frontend and lib layer (DTOs in src/types/api.ts); zero
  eslint errors
- Update README and Unraid guide for migrations, upgrade path, and API

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-01 19:43:36 -05:00

107 lines
2.3 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"
}
datasource db {
provider = "sqlite"
}
model Account {
id String @id @default(cuid())
userId String
type String
provider String
providerAccountId String
refresh_token String?
access_token String?
expires_at Int?
token_type String?
scope String?
id_token String?
session_state String?
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@unique([provider, providerAccountId])
}
model Session {
id String @id @default(cuid())
sessionToken String @unique
userId String
expires DateTime
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
}
model User {
id String @id @default(cuid())
name String?
email String? @unique
emailVerified DateTime?
image String?
role Role @default(EMPLOYEE)
accounts Account[]
sessions Session[]
reports Report[]
}
model VerificationToken {
identifier String
token String @unique
expires DateTime
@@unique([identifier, token])
}
enum Role {
EMPLOYEE
ADMIN
}
model Report {
id String @id @default(cuid())
date DateTime @default(now())
managerName String
status ReportStatus @default(IN_PROGRESS)
driveFileId String?
userId String
user User @relation(fields: [userId], references: [id])
tasks Task[]
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@unique([userId, date])
}
enum ReportStatus {
IN_PROGRESS
COMPLETED
SUBMITTED
}
model Task {
id String @id @default(cuid())
type TaskType
description String
timeEstimate String?
notes String?
status String? @default("PENDING") // For completed tasks: DONE, IN_PROGRESS, etc.
link String? // Google Drive link
reportId String
report Report @relation(fields: [reportId], references: [id], onDelete: Cascade)
}
model Setting {
id String @id @default(cuid())
key String @unique
value String
}
enum TaskType {
PLANNED
COMPLETED
}