diff --git a/migrations/2024-04-06-053500_timetable-compression-v1/down.sql b/migrations/2024-04-06-053500_timetable-compression-v1/down.sql index 91e6c6e4..6227ea7b 100644 --- a/migrations/2024-04-06-053500_timetable-compression-v1/down.sql +++ b/migrations/2024-04-06-053500_timetable-compression-v1/down.sql @@ -22,4 +22,45 @@ CREATE TABLE gtfs.stoptimes ( PRIMARY KEY (onestop_feed_id, attempt_id, trip_id, stop_sequence) ); -CREATE INDEX stoptimes_chateau_idx ON gtfs.stoptimes (chateau); \ No newline at end of file +CREATE INDEX stoptimes_chateau_idx ON gtfs.stoptimes (chateau); + +CREATE TABLE gtfs.trips ( + onestop_feed_id text NOT NULL, + trip_id text NOT NULL, + attempt_id text NOT NULL, + route_id text NOT NULL, + service_id text NOT NULL, + trip_headsign text, + trip_headsign_translations jsonb, + has_stop_headsigns boolean NOT NULL, + stop_headsigns text[], + trip_short_name text, + direction_id smallint, + block_id text, + shape_id text, + wheelchair_accessible smallint NOT NULL, + bikes_allowed smallint NOT NULL, + chateau text NOT NULL, + frequencies trip_frequency[], + has_frequencies boolean NOT NULL, + PRIMARY KEY (onestop_feed_id, attempt_id, trip_id) +); + +CREATE TABLE gtfs.trip_frequencies ( + onestop_feed_id text NOT NULL, + trip_id text NOT NULL, + attempt_id text NOT NULL, + index smallint NOT NULL, + start_time OID NOT NULL, + end_time OID NOT NULL, + headway_secs OID NOT NULL, + -- a false means 0 or FrequencyBased, true means ScheduleBased or 1 + exact_times boolean NOT NULL, + PRIMARY KEY (onestop_feed_id, attempt_id, trip_id, index) +); + +CREATE INDEX IF NOT EXISTS trips_chateau ON gtfs.trips (chateau); + +DROP TABLE gtfs.itinerary_pattern CASCADE; +DROP TABLE gtfs.itinerary_pattern_meta CASCADE; +DROP TABLE gtfs.trips_compressed CASCADE; \ No newline at end of file diff --git a/migrations/2024-04-06-053500_timetable-compression-v1/up.sql b/migrations/2024-04-06-053500_timetable-compression-v1/up.sql index 2570a694..f82e425c 100644 --- a/migrations/2024-04-06-053500_timetable-compression-v1/up.sql +++ b/migrations/2024-04-06-053500_timetable-compression-v1/up.sql @@ -1,6 +1,6 @@ --- Your SQL goes here DROP TABLE IF EXISTS gtfs.stoptimes CASCADE; DROP TABLE IF EXISTS gtfs.trips CASCADE; +DROP TABLE IF EXISTS gtfs.frequencies CASCADE; -- row by row CREATE TABLE gtfs.itinerary_pattern ( @@ -44,6 +44,7 @@ CREATE TABLE gtfs.trips_compressed ( frequencies trip_frequency[], has_frequencies boolean NOT NULL, itinerary_pattern_id text NOT NULL, + compressed_trip_frequencies text, PRIMARY KEY (onestop_feed_id, attempt_id, trip_id) );