Skip to content

Commit

Permalink
move wkt to route and refactor alert decode
Browse files Browse the repository at this point in the history
  • Loading branch information
jonerrr committed Aug 14, 2024
1 parent f7918b8 commit 0763087
Show file tree
Hide file tree
Showing 17 changed files with 375 additions and 213 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

This file was deleted.

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions backend/migrations/20240526185042_alerts.down.sql

This file was deleted.

3 changes: 2 additions & 1 deletion backend/migrations/20240609200239_bus_routes.up.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ CREATE TABLE IF NOT EXISTS bus_routes (
long_name VARCHAR NOT NULL,
short_name VARCHAR NOT NULL,
color VARCHAR NOT NULL,
shuttle BOOLEAN NOT NULL
shuttle BOOLEAN NOT NULL,
wkt VARCHAR NOT NULL
);
11 changes: 1 addition & 10 deletions backend/migrations/20240609200453_bus_stops.up.sql
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,5 @@ CREATE TABLE IF NOT EXISTS bus_route_stops (
-- can be 1 or 0
-- each route has two directions with separate stops
direction INTEGER NOT NULL,
geom VARCHAR NOT NULL,
PRIMARY KEY (route_id, stop_id, stop_sequence)
);

-- CREATE TABLE IF NOT EXISTS bus_stop_groups (
-- route_id VARCHAR REFERENCES bus_routes(id),
-- -- same direction as the route stops
-- direction INTEGER NOT NULL,
-- headsign VARCHAR NOT NULL,
-- PRIMARY KEY (route_id, direction)
-- );
);
9 changes: 9 additions & 0 deletions backend/migrations/20240813211652_alerts.down.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
DROP INDEX IF EXISTS idx_active_periods_alert_id_start_time_end_time;

DROP INDEX IF EXISTS idx_affected_entities_alert_id_route_id;

DROP TABLE IF EXISTS affected_entities;

DROP TABLE IF EXISTS active_periods;

DROP TABLE IF EXISTS alerts;
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,19 @@ CREATE TABLE IF NOT EXISTS alerts (
CREATE TABLE IF NOT EXISTS active_periods(
alert_id UUID NOT NULL REFERENCES alerts(id) ON DELETE CASCADE,
start_time TIMESTAMP WITH TIME ZONE NOT NULL,
end_time TIMESTAMP WITH TIME ZONE
end_time TIMESTAMP WITH TIME ZONE,
PRIMARY KEY (alert_id, start_time)
);

CREATE TABLE IF NOT EXISTS affected_entities(
alert_id UUID NOT NULL REFERENCES alerts(id) ON DELETE CASCADE,
route_id VARCHAR REFERENCES routes(id),
stop_id VARCHAR REFERENCES stops(id),
sort_order INTEGER NOT NULL
bus_route_id VARCHAR REFERENCES bus_routes(id),
sort_order INTEGER NOT NULL,
UNIQUE (alert_id, route_id, stop_id, bus_route_id)
);

-- CREATE INDEX idx_alerts_id ON alerts (id);
-- CREATE INDEX idx_active_periods_alert_id_start_time_end_time ON active_periods (alert_id, start_time, end_time);
-- CREATE INDEX idx_affected_entities_alert_id_route_id ON affected_entities (alert_id, route_id);
CREATE INDEX idx_active_periods_alert_id_start_time_end_time ON active_periods (alert_id, start_time, end_time);

CREATE INDEX idx_affected_entities_alert_id_route_id ON affected_entities (alert_id, route_id);
Loading

0 comments on commit 0763087

Please sign in to comment.