mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-30 04:08:11 +00:00
Migration issue resolution
This commit is contained in:
@@ -4,5 +4,17 @@
|
||||
- A unique constraint covering the columns `[scheduleId,seatId,departureStationId]` on the table `JourneySegment` will be added. If there are existing duplicate values, this will fail.
|
||||
|
||||
*/
|
||||
-- Deduplicate before applying the unique index.
|
||||
-- Keeps the row with the lowest id per (scheduleId, seatId, departureStationId) group.
|
||||
DELETE FROM passenger."JourneySegment"
|
||||
WHERE id NOT IN (
|
||||
SELECT MIN(id)
|
||||
FROM passenger."JourneySegment"
|
||||
WHERE "seatId" IS NOT NULL
|
||||
GROUP BY "scheduleId", "seatId", "departureStationId"
|
||||
)
|
||||
AND "seatId" IS NOT NULL;
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS "JourneySegment_scheduleId_seatId_departureStationId_key" ON "JourneySegment"("scheduleId", "seatId", "departureStationId");
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS "JourneySegment_scheduleId_seatId_departureStationId_key"
|
||||
ON "JourneySegment"("scheduleId", "seatId", "departureStationId");
|
||||
|
||||
Reference in New Issue
Block a user