fix(seed): Update seed.js with correct Role Enum values (GROWER, STAFF)
Some checks failed
Deploy to Production / deploy (push) Failing after 0s
Test / backend-test (push) Failing after 0s
Test / frontend-test (push) Failing after 0s

This commit is contained in:
fullsizemalt 2025-12-11 11:51:00 -08:00
parent deadb04803
commit 9188d12475

View file

@ -36,7 +36,7 @@ async function main() {
isSystem: true isSystem: true
}, },
{ {
name: 'Cultivator', name: 'Grower',
description: 'Plant care and daily operations', description: 'Plant care and daily operations',
permissions: { permissions: {
tasks: { view: true, complete: true }, tasks: { view: true, complete: true },
@ -76,7 +76,7 @@ async function main() {
const ownerRole = await prisma.role.findUnique({ where: { name: 'Facility Owner' } }); const ownerRole = await prisma.role.findUnique({ where: { name: 'Facility Owner' } });
const managerRole = await prisma.role.findUnique({ where: { name: 'Manager' } }); const managerRole = await prisma.role.findUnique({ where: { name: 'Manager' } });
const cultivatorRole = await prisma.role.findUnique({ where: { name: 'Cultivator' } }); const cultivatorRole = await prisma.role.findUnique({ where: { name: 'Grower' } });
const workerRole = await prisma.role.findUnique({ where: { name: 'Worker' } }); const workerRole = await prisma.role.findUnique({ where: { name: 'Worker' } });
// ==================== USERS ==================== // ==================== USERS ====================
@ -102,7 +102,7 @@ async function main() {
email: 'cultivator@demo.local', email: 'cultivator@demo.local',
password: 'demo1234', password: 'demo1234',
name: `${DEMO_PREFIX} Mike Thompson`, name: `${DEMO_PREFIX} Mike Thompson`,
role: 'CULTIVATOR', role: 'GROWER',
roleId: cultivatorRole?.id, roleId: cultivatorRole?.id,
rate: 28.00 rate: 28.00
}, },
@ -110,7 +110,7 @@ async function main() {
email: 'worker@demo.local', email: 'worker@demo.local',
password: 'demo1234', password: 'demo1234',
name: `${DEMO_PREFIX} Alex Rivera`, name: `${DEMO_PREFIX} Alex Rivera`,
role: 'WORKER', role: 'STAFF',
roleId: workerRole?.id, roleId: workerRole?.id,
rate: 22.00 rate: 22.00
} }
@ -158,38 +158,36 @@ async function main() {
} }
// ==================== BATCHES ==================== // ==================== BATCHES ====================
console.log('\n🌿 Creating Demo Batches...'); console.log('\n🌱 Creating Demo Batches...');
const cultivator = await prisma.user.findFirst({ where: { email: 'cultivator@demo.local' } });
const batchesData = [ const batchesData = [
{ {
name: `${DEMO_PREFIX} OG Kush - Batch 001`, name: `${DEMO_PREFIX} Gorilla Glue #4 - Batch 001`,
strain: 'OG Kush', strain: 'Gorilla Glue #4',
status: 'ACTIVE', status: 'ACTIVE',
stage: 'VEGETATIVE', stage: 'FLOWERING',
source: 'CLONE', source: 'CLONE',
plantCount: 48, plantCount: 450,
startDate: new Date(Date.now() - 14 * 24 * 60 * 60 * 1000), // 14 days ago startDate: new Date(Date.now() - 45 * 24 * 60 * 60 * 1000), // 45 days ago
roomId: createdRooms.find(r => r.name.includes('Veg Room 1'))?.id roomId: createdRooms.find(r => r.name.includes('Flower Room A'))?.id
}, },
{ {
name: `${DEMO_PREFIX} Blue Dream - Batch 002`, name: `${DEMO_PREFIX} Blue Dream - Batch 002`,
strain: 'Blue Dream', strain: 'Blue Dream',
status: 'ACTIVE', status: 'ACTIVE',
stage: 'FLOWERING', stage: 'VEGETATIVE',
source: 'CLONE', source: 'CLONE',
plantCount: 36, plantCount: 300,
startDate: new Date(Date.now() - 45 * 24 * 60 * 60 * 1000), // 45 days ago startDate: new Date(Date.now() - 20 * 24 * 60 * 60 * 1000), // 20 days ago
roomId: createdRooms.find(r => r.name.includes('Flower Room A'))?.id roomId: createdRooms.find(r => r.name.includes('Veg Room 1'))?.id
}, },
{ {
name: `${DEMO_PREFIX} Girl Scout Cookies - Batch 003`, name: `${DEMO_PREFIX} Wedding Cake - Batch 003`,
strain: 'Girl Scout Cookies', strain: 'Wedding Cake',
status: 'ACTIVE', status: 'ACTIVE',
stage: 'FLOWERING', stage: 'FLOWERING',
source: 'SEED', source: 'CLONE',
plantCount: 24, plantCount: 400,
startDate: new Date(Date.now() - 52 * 24 * 60 * 60 * 1000), // 52 days ago startDate: new Date(Date.now() - 10 * 24 * 60 * 60 * 1000), // 10 days ago (Just flipped)
roomId: createdRooms.find(r => r.name.includes('Flower Room B'))?.id roomId: createdRooms.find(r => r.name.includes('Flower Room B'))?.id
}, },
{ {
@ -272,6 +270,7 @@ async function main() {
// ==================== TASKS ==================== // ==================== TASKS ====================
console.log('\n✅ Creating Demo Tasks...'); console.log('\n✅ Creating Demo Tasks...');
const manager = await prisma.user.findFirst({ where: { email: 'manager@demo.local' } }); const manager = await prisma.user.findFirst({ where: { email: 'manager@demo.local' } });
const cultivator = await prisma.user.findFirst({ where: { email: 'cultivator@demo.local' } });
const tasksData = [ const tasksData = [
{ {