- Add prisma/schema.prisma with Project/Task models, enums, and relations - Create src/lib/db.ts singleton Prisma client - Refactor all 5 API routes to use Prisma queries - Replace migrate.ts with seed.ts for initial data - Update Dockerfile for Prisma lifecycle (copy generated client) - Update tsconfig.json with @/generated/* path alias - Remove pg and @types/pg dependencies - Add prisma.config.ts for Prisma 6 config - Update .gitignore for generated Prisma client
77 lines
2.0 KiB
Plaintext
77 lines
2.0 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"
|
|
output = "../src/generated/prisma"
|
|
}
|
|
|
|
datasource db {
|
|
provider = "postgresql"
|
|
url = env("DATABASE_URL")
|
|
}
|
|
|
|
model Project {
|
|
id String @id @default(uuid()) @db.Uuid
|
|
name String
|
|
description String @default("")
|
|
color String @default("#3b82f6")
|
|
sortOrder Int @default(0) @map("sort_order")
|
|
createdAt DateTime @default(now()) @map("created_at")
|
|
updatedAt DateTime @updatedAt @map("updated_at")
|
|
tasks Task[]
|
|
|
|
@@index([sortOrder])
|
|
}
|
|
|
|
model Task {
|
|
id String @id @default(uuid()) @db.Uuid
|
|
title String
|
|
description String @default("")
|
|
completed Boolean @default(false)
|
|
priority Priority @default(medium)
|
|
dueDate DateTime? @map("due_date")
|
|
status Status @default(todo)
|
|
parentTaskId String? @map("parent_task_id") @db.Uuid
|
|
recurrenceRule Recurrence @default(none) @map("recurrence_rule")
|
|
recurrenceInterval Int @default(1) @map("recurrence_interval")
|
|
nextOccurrence DateTime? @map("next_occurrence")
|
|
sortOrder Int @default(0) @map("sort_order")
|
|
createdAt DateTime @default(now()) @map("created_at")
|
|
updatedAt DateTime @updatedAt @map("updated_at")
|
|
|
|
parentTask Task? @relation("TaskChildren", fields: [parentTaskId], references: [id], onDelete: Cascade)
|
|
children Task[] @relation("TaskChildren")
|
|
project Project? @relation(fields: [projectId], references: [id], onDelete: Cascade)
|
|
projectId String? @map("project_id") @db.Uuid
|
|
|
|
@@index([projectId])
|
|
@@index([parentTaskId])
|
|
@@index([completed])
|
|
@@index([status])
|
|
@@index([dueDate])
|
|
@@index([recurrenceRule])
|
|
}
|
|
|
|
enum Priority {
|
|
low
|
|
medium
|
|
high
|
|
urgent
|
|
}
|
|
|
|
enum Status {
|
|
todo
|
|
in_progress
|
|
done
|
|
}
|
|
|
|
enum Recurrence {
|
|
none
|
|
daily
|
|
weekly
|
|
biweekly
|
|
monthly
|
|
yearly
|
|
}
|