-- One-time cleanup for hold_seats (run in phpMyAdmin on production DB).
-- Times in hold_seats.startdate / enddate are Egypt (Cairo) wall clock.
-- Prefer app auto-expire: HoldSeatSupport::expireStaleAdminHolds() uses EgyptTime::parse('now').
-- Before running UPDATE: SET time_zone = '+03:00';  (or +02:00 in winter — match Egypt offset)

SET time_zone = '+03:00';

UPDATE hold_seats
SET status = 0,
    updated_at = NOW()
WHERE status = 1
  AND enddate < NOW();

-- Trip 74 / journey 2026-05-26 test hold (id 126) after window ended:
-- UPDATE hold_seats SET status = 0, updated_at = NOW() WHERE id IN (126);

-- Verify active holds for trip 74:
-- SELECT id, trip_id, seat_number, journeydata, journeydataend, startdate, enddate, status
-- FROM hold_seats
-- WHERE trip_id = 74 AND status = 1;
