From df992eb7946e57f1117bf50ceeabb5fdbd99f651 Mon Sep 17 00:00:00 2001 From: Roba Boru Date: Sun, 19 Jul 2026 17:10:57 +0300 Subject: [PATCH] fix: add partial WHERE clause to JourneySegment unique index migration Without WHERE ("seatId" IS NOT NULL) the index creation fails in environments that have JourneySegment rows with NULL seatId sharing the same (scheduleId, departureStationId), which aborts the CI/CD pipeline before the API server restarts. Also adds the passenger. schema prefix to match the DELETE statement above it. Co-Authored-By: Claude Sonnet 4.6 --- .../migration.sql | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/apps/edr-passenger-api/prisma/migrations/20260718144855_unique_constraint_schedule_id_seat_id_departure_station_id/migration.sql b/apps/edr-passenger-api/prisma/migrations/20260718144855_unique_constraint_schedule_id_seat_id_departure_station_id/migration.sql index a512eeccd..d19281e3c 100644 --- a/apps/edr-passenger-api/prisma/migrations/20260718144855_unique_constraint_schedule_id_seat_id_departure_station_id/migration.sql +++ b/apps/edr-passenger-api/prisma/migrations/20260718144855_unique_constraint_schedule_id_seat_id_departure_station_id/migration.sql @@ -15,6 +15,7 @@ WHERE id NOT IN ( ) AND "seatId" IS NOT NULL; --- CreateIndex +-- CreateIndex (partial: only index rows where seatId is not null so NULL rows never collide) CREATE UNIQUE INDEX IF NOT EXISTS "JourneySegment_scheduleId_seatId_departureStationId_key" - ON "JourneySegment"("scheduleId", "seatId", "departureStationId"); + ON passenger."JourneySegment"("scheduleId", "seatId", "departureStationId") + WHERE ("seatId" IS NOT NULL);