Support schedule trip variants

This commit is contained in:
2026-05-22 02:07:05 +03:00
parent 4a607d448b
commit edf3c1052b
7 changed files with 922 additions and 196 deletions

View File

@@ -0,0 +1,26 @@
-- Per-departure metadata for partial, via-stop, and calendar-specific trips.
-- Existing clients can continue to use departure_times; trips is the richer source.
ALTER TABLE schedules
ADD COLUMN IF NOT EXISTS trips JSONB NOT NULL DEFAULT '[]'::jsonb;
UPDATE schedules
SET trips = (
SELECT COALESCE(
jsonb_agg(
jsonb_build_object(
'departureTime', to_char(departure_time, 'HH24:MI:SS'),
'startStopId', NULL,
'endStopId', NULL,
'viaStopIds', '[]'::jsonb,
'daysOfWeek', '[]'::jsonb,
'exceptDaysOfWeek', '[]'::jsonb,
'note', ''
)
ORDER BY departure_time
),
'[]'::jsonb
)
FROM unnest(departure_times) AS expanded_departures(departure_time)
)
WHERE trips = '[]'::jsonb
AND departure_times IS NOT NULL;