-- One-time fixes: journeylists.journeydate = BUS RUN day; tickets.journeydata = BOARDING day.
--
-- Run on production after deploying busRunForBooking normalize-only fix.

-- Trip 75 / subtrip 404 midnight (Aug 2026): list was boarding day
UPDATE journeylists jl
INNER JOIN tickets t ON t.booking_id = jl.booking_id AND t.trip_id = jl.trip_id
SET jl.journeydate = '2026-08-02'
WHERE jl.trip_id = 75
  AND jl.journeydate = '2026-08-03'
  AND DATE(t.journeydata) = '2026-08-03'
  AND jl.booking_id IN ('TBDGXIBWVS', 'TB8MYU5QS2');

-- TB1A236ULR (trip 75 / subtrip 238, 12:45 AM on 2026-06-15 bus run)
UPDATE tickets
SET journeydata = '2026-06-16 00:00:00'
WHERE booking_id = 'TB1A236ULR'
  AND trip_id = 75
  AND DATE(journeydata) = '2026-06-15';

UPDATE journeylists
SET journeydate = '2026-06-15'
WHERE booking_id = 'TB1A236ULR'
  AND trip_id = 75
  AND journeydate = '2026-06-14';

-- TBRLPUHAOS (same run / seat 14 — journeydata must be boarding day)
UPDATE tickets
SET journeydata = '2026-06-16 00:00:00'
WHERE booking_id = 'TBRLPUHAOS'
  AND trip_id = 75
  AND DATE(journeydata) = '2026-06-15';

-- TBX1SO6Q0G (trip 75 / subtrip 238, 01:00 AM on 2026-06-18 bus run)
UPDATE tickets
SET journeydata = '2026-06-19 00:00:00'
WHERE booking_id = 'TBX1SO6Q0G'
  AND trip_id = 75
  AND DATE(journeydata) = '2026-06-18';
