ca-grow-ops-manager/backend/prisma/schema.prisma
fullsizemalt f95b626724 feat: Shopping List UI + Roadmap Update
📦 Shopping List Feature (Phase 3A)
- Full SupplyItem model with Vendor & ProductUrl
- Shopping List / Inventory toggle
- Add Item Modal (Category, Thresholds, Vendor info)
- 'Order Now' external link logic
- 'Mark Ordered' tracking
- Quantity +/- adjustments

📅 Roadmap Update:
- Defined Unified Master Calendar (Phase 4)
- Added granular toggles (Emp Schedules, Taxes, Compliance, Plant Cycle, etc.)

🚀 Status:
- Backend deployed (Schema synced)
- Frontend deploying...
2025-12-09 15:26:35 -08:00

273 lines
6.4 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
}
// Daily Walkthrough Enums
enum WalkthroughStatus {
IN_PROGRESS
COMPLETED
INCOMPLETE
}
enum TankType {
VEG
FLOWER
}
enum TankStatus {
OK
LOW
CRITICAL
}
enum HealthStatus {
GOOD
FAIR
NEEDS_ATTENTION
}
enum AccessStatus {
OK
ISSUES
}
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[]
walkthroughs DailyWalkthrough[]
@@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")
}
// Daily Walkthrough Models
model DailyWalkthrough {
id String @id @default(uuid())
date DateTime @default(now())
completedBy String
user User @relation(fields: [completedBy], references: [id])
startTime DateTime @default(now())
endTime DateTime?
status WalkthroughStatus @default(IN_PROGRESS)
reservoirChecks ReservoirCheck[]
irrigationChecks IrrigationCheck[]
plantHealthChecks PlantHealthCheck[]
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@map("daily_walkthroughs")
}
model ReservoirCheck {
id String @id @default(uuid())
walkthroughId String
walkthrough DailyWalkthrough @relation(fields: [walkthroughId], references: [id], onDelete: Cascade)
tankName String
tankType TankType
levelPercent Int
status TankStatus
photoUrl String?
notes String?
createdAt DateTime @default(now())
@@map("reservoir_checks")
}
model IrrigationCheck {
id String @id @default(uuid())
walkthroughId String
walkthrough DailyWalkthrough @relation(fields: [walkthroughId], references: [id], onDelete: Cascade)
zoneName String // "Veg Upstairs", "Veg Downstairs", "Flower Upstairs", "Flower Downstairs"
drippersTotal Int
drippersWorking Int
drippersFailed String? // JSON array of failed dripper IDs
waterFlow Boolean
nutrientsMixed Boolean
scheduleActive Boolean
photoUrl String? // Photo of working system
issues String?
createdAt DateTime @default(now())
@@map("irrigation_checks")
}
model PlantHealthCheck {
id String @id @default(uuid())
walkthroughId String
walkthrough DailyWalkthrough @relation(fields: [walkthroughId], references: [id], onDelete: Cascade)
zoneName String
healthStatus HealthStatus
pestsObserved Boolean
pestType String?
waterAccess AccessStatus
foodAccess AccessStatus
flaggedForAttention Boolean @default(false)
issuePhotoUrl String?
referencePhotoUrl String? // Photo of healthy system
notes String?
createdAt DateTime @default(now())
@@map("plant_health_checks")
}
// Supply/Shopping List models
model SupplyItem {
id String @id @default(uuid())
name String
category SupplyCategory
quantity Int @default(0)
minThreshold Int @default(0)
unit String // "each", "box", "roll", "gallon", etc.
location String? // "Storage Room", "Bathroom", etc.
vendor String? // "Amazon", "Local", etc.
productUrl String? // Link to reorder
lastOrdered DateTime?
notes String?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@map("supply_items")
}
enum SupplyCategory {
FILTER // Air filters, water filters
CLEANING // Cleaning supplies
PPE // Gloves, masks, suits
OFFICE // Paper, pens, etc.
BATHROOM // Toilet paper, soap, etc.
KITCHEN // Coffee, snacks, etc.
MAINTENANCE // Tools, parts, etc.
OTHER
}