135 lines
2.8 KiB
Text
135 lines
2.8 KiB
Text
generator client {
|
|
provider = "prisma-client-js"
|
|
}
|
|
|
|
datasource db {
|
|
provider = "postgresql"
|
|
url = env("DATABASE_URL")
|
|
}
|
|
|
|
enum Role {
|
|
OWNER
|
|
MANAGER
|
|
GROWER
|
|
STAFF
|
|
}
|
|
|
|
enum RoomType {
|
|
VEG
|
|
FLOWER
|
|
DRY
|
|
CURE
|
|
MOTHER
|
|
CLONE
|
|
}
|
|
|
|
enum TaskStatus {
|
|
PENDING
|
|
IN_PROGRESS
|
|
COMPLETED
|
|
BLOCKED
|
|
}
|
|
|
|
model User {
|
|
id String @id @default(uuid())
|
|
email String @unique
|
|
passwordHash String
|
|
name String?
|
|
role Role @default(STAFF)
|
|
rate Decimal? @map("hourly_rate") // For labor cost calc
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
tasks TaskInstance[]
|
|
timeLogs TimeLog[]
|
|
|
|
@@map("users")
|
|
}
|
|
|
|
model Room {
|
|
id String @id @default(uuid())
|
|
name String
|
|
type RoomType
|
|
sqft Float?
|
|
width Float?
|
|
length Float?
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
batches Batch[]
|
|
tasks TaskInstance[]
|
|
|
|
@@map("rooms")
|
|
}
|
|
|
|
model Batch {
|
|
id String @id @default(uuid())
|
|
name String // e.g., "B-2023-10-15-GG4"
|
|
strain String
|
|
startDate DateTime
|
|
harvestDate DateTime?
|
|
status String @default("ACTIVE") // ACTIVE, HARVESTED, COMPLETED
|
|
|
|
roomId String?
|
|
room Room? @relation(fields: [roomId], references: [id])
|
|
|
|
tasks TaskInstance[]
|
|
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
@@map("batches")
|
|
}
|
|
|
|
model TaskTemplate {
|
|
id String @id @default(uuid())
|
|
title String
|
|
description String?
|
|
estimatedMinutes Int?
|
|
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
@@map("task_templates")
|
|
}
|
|
|
|
model TaskInstance {
|
|
id String @id @default(uuid())
|
|
title String // Copied from template or custom
|
|
description String?
|
|
status TaskStatus @default(PENDING)
|
|
priority String @default("MEDIUM")
|
|
|
|
assignedToId String?
|
|
assignedTo User? @relation(fields: [assignedToId], references: [id])
|
|
|
|
batchId String?
|
|
batch Batch? @relation(fields: [batchId], references: [id])
|
|
|
|
roomId String?
|
|
room Room? @relation(fields: [roomId], references: [id])
|
|
|
|
completedAt DateTime?
|
|
dueDate DateTime?
|
|
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
@@map("task_instances")
|
|
}
|
|
|
|
model TimeLog {
|
|
id String @id @default(uuid())
|
|
userId String
|
|
user User @relation(fields: [userId], references: [id])
|
|
|
|
startTime DateTime
|
|
endTime DateTime?
|
|
activityType String? // e.g. "Trimming", "Feeding", "Cleaning"
|
|
notes String?
|
|
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
@@map("time_logs")
|
|
}
|