Skip to content

Commit

Permalink
add compressed trip frequencies to the trips compressed table
Browse files Browse the repository at this point in the history
  • Loading branch information
kylerchin committed Apr 6, 2024
1 parent ae0f29f commit e9b2016
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 2 deletions.
43 changes: 42 additions & 1 deletion migrations/2024-04-06-053500_timetable-compression-v1/down.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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);
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;
3 changes: 2 additions & 1 deletion migrations/2024-04-06-053500_timetable-compression-v1/up.sql
Original file line number Diff line number Diff line change
@@ -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 (
Expand Down Expand Up @@ -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)
);

Expand Down

0 comments on commit e9b2016

Please sign in to comment.