From 11192b6d49c3ba18a45cb28b89db135ff0e28870 Mon Sep 17 00:00:00 2001 From: Abubeker Yasin Date: Mon, 8 Jun 2026 11:35:12 +0300 Subject: [PATCH 1/2] fix(passenger-api): fix seed TypeScript errors for dev --- apps/edr-passenger-api/prisma/seed.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/apps/edr-passenger-api/prisma/seed.ts b/apps/edr-passenger-api/prisma/seed.ts index aed68df65..f29815996 100644 --- a/apps/edr-passenger-api/prisma/seed.ts +++ b/apps/edr-passenger-api/prisma/seed.ts @@ -147,9 +147,9 @@ async function seedCoachTypesAndClasses() { for (const ct of coachTypes) { await prisma.coachType.upsert({ - where: { code: ct.code }, + where: { id: ct.code }, update: {}, - create: ct, + create: { ...ct, id: ct.code }, }); } @@ -161,7 +161,7 @@ async function seedCoachTypesAndClasses() { ]; for (const sc of seatClasses) { - const ct = await prisma.coachType.findUnique({ where: { code: sc.coachCode } }); + const ct = await prisma.coachType.findUnique({ where: { id: sc.coachCode } }); await prisma.seatClass.upsert({ where: { coachTypeId_name: { coachTypeId: ct!.id, name: sc.name } }, update: {}, @@ -204,9 +204,9 @@ async function seedRoute() { async function seedCoaches() { console.log('\n🚃 Seeding coaches and seats...'); - const ecoCoachType = await prisma.coachType.findUnique({ where: { code: 'ECO' } }); - const ecoBedCoachType = await prisma.coachType.findUnique({ where: { code: 'ECO_BED' } }); - const vipBedCoachType = await prisma.coachType.findUnique({ where: { code: 'VIP_BED' } }); + const ecoCoachType = await prisma.coachType.findUnique({ where: { id: 'ECO' } }); + const ecoBedCoachType = await prisma.coachType.findUnique({ where: { id: 'ECO_BED' } }); + const vipBedCoachType = await prisma.coachType.findUnique({ where: { id: 'VIP_BED' } }); const coaches = [ { number: 'C-001', coachTypeId: ecoCoachType!.id, arrangement: '2+2', capacity: 48 }, @@ -330,7 +330,7 @@ async function seedFareRules() { fareRules.push({ routeId: route!.id, seatClassId: sc.id, - passengerCategory: 'ADULT', + passengerCategory: 'ADULT' as const, baseFareMinor: sc.baseFareMinor, currency: 'ETB', validFrom, @@ -338,7 +338,7 @@ async function seedFareRules() { fareRules.push({ routeId: route!.id, seatClassId: sc.id, - passengerCategory: 'CHILD', + passengerCategory: 'CHILD' as const, baseFareMinor: Math.floor(sc.baseFareMinor * 0.5), discountPercent: 50, currency: 'ETB', @@ -396,7 +396,7 @@ async function seedPaymentMethods() { await prisma.paymentMethod.upsert({ where: { type: m.type as any }, update: {}, - create: m, + create: { ...m, type: m.type as any, region: m.region as any }, }); } console.log(` āœ… ${methods.length} payment methods created`); From d07f522a606cd1d1d59ede09bb84de35500ce820 Mon Sep 17 00:00:00 2001 From: Abubeker Yasin Date: Mon, 8 Jun 2026 12:00:01 +0300 Subject: [PATCH 2/2] fix(passenger-api): fix seed errors and add missing stop times --- apps/edr-passenger-api/prisma/seed.ts | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/apps/edr-passenger-api/prisma/seed.ts b/apps/edr-passenger-api/prisma/seed.ts index f29815996..9aff71529 100644 --- a/apps/edr-passenger-api/prisma/seed.ts +++ b/apps/edr-passenger-api/prisma/seed.ts @@ -311,12 +311,31 @@ async function seedTrips() { }); } + // Stop times: one TripStopTime per station per schedule + const stationCodes = ['SBT', 'LEB', 'BSH', 'MOJ', 'ADM', 'MTE', 'MIS', 'BIK', 'DRE', 'ADG', 'AYS', 'DAW', 'ALS', 'HOL', 'NAG']; + const stopTimeRows = []; + for (const schedule of createdSchedules) { + const dep = new Date(schedule.departureAt); + for (let i = 0; i < stationCodes.length; i++) { + const stationId = `station-${stationCodes[i].toLowerCase()}`; + const offsetMs = i * 60 * 60 * 1000; // ~1 hour between stops + stopTimeRows.push({ + scheduleId: schedule.id, + stationId, + sequence: i + 1, + plannedArrivalAt: i === 0 ? null : new Date(dep.getTime() + offsetMs), + plannedDepartureAt: i === stationCodes.length - 1 ? null : new Date(dep.getTime() + offsetMs), + }); + } + } + await Promise.all([ ...coachAssignments.map(ca => prisma.coachAssignment.create({ data: ca })), ...liveStatuses.map(ls => prisma.tripLiveStatus.create({ data: ls })), + prisma.tripStopTime.createMany({ data: stopTimeRows }), ]); - - console.log(` āœ… Train with ${createdSchedules.length} upcoming trips created`); + + console.log(` āœ… Train with ${createdSchedules.length} upcoming trips and stop times created`); } async function seedFareRules() {