feat: Daily Walkthrough Database Schema
🔴 Phase 1.5: Daily Operations for 777 Wolfpack ✅ Database Schema Complete: - DailyWalkthrough model (parent walkthrough session) - ReservoirCheck model (tank levels, veg/flower) - IrrigationCheck model (drippers, water flow, nutrients, 4 zones) - PlantHealthCheck model (pests, water/food access, photos) 📊 New Enums: - WalkthroughStatus (IN_PROGRESS, COMPLETED, INCOMPLETE) - TankType (VEG, FLOWER) - TankStatus (OK, LOW, CRITICAL) - HealthStatus (GOOD, FAIR, NEEDS_ATTENTION) - AccessStatus (OK, ISSUES) 🔗 Relationships: - User → DailyWalkthrough (one-to-many) - DailyWalkthrough → ReservoirCheck (one-to-many, cascade delete) - DailyWalkthrough → IrrigationCheck (one-to-many, cascade delete) - DailyWalkthrough → PlantHealthCheck (one-to-many, cascade delete) 📝 Features: - Photo URLs for all check types - JSON storage for failed dripper IDs - Cascade delete (cleanup on walkthrough deletion) - Timestamps for audit trail - Status tracking (in progress → completed) ⏭️ Next: Migration + Backend API endpoints Migration Command (run on deployment): npx prisma migrate dev --name add_daily_walkthrough
This commit is contained in:
parent
8105c2f05c
commit
7d42ecbfad
1 changed files with 108 additions and 0 deletions
|
|
@ -30,6 +30,35 @@ enum TaskStatus {
|
||||||
BLOCKED
|
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 {
|
model User {
|
||||||
id String @id @default(uuid())
|
id String @id @default(uuid())
|
||||||
email String @unique
|
email String @unique
|
||||||
|
|
@ -42,6 +71,7 @@ model User {
|
||||||
|
|
||||||
tasks TaskInstance[]
|
tasks TaskInstance[]
|
||||||
timeLogs TimeLog[]
|
timeLogs TimeLog[]
|
||||||
|
walkthroughs DailyWalkthrough[]
|
||||||
|
|
||||||
@@map("users")
|
@@map("users")
|
||||||
}
|
}
|
||||||
|
|
@ -133,3 +163,81 @@ model TimeLog {
|
||||||
|
|
||||||
@@map("time_logs")
|
@@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")
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue