Skip to content

Commit 5378711

Browse files
committed
orphan removal helper script
This should actually be part of the import app functionality. Save for future reference.
1 parent 1a21e5a commit 5378711

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

scripts/orphan-removal.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/env bash
2+
3+
set -eu
4+
5+
SCRIPT_DIR="$(dirname "$(realpath "$0")")"
6+
psql -h localhost -p 6432 -d jore4e2e -U dbadmin -f "$SCRIPT_DIR/orphan-removal.sql"

scripts/orphan-removal.sql

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
DELETE FROM journey_pattern.journey_pattern jp
2+
WHERE NOT EXISTS (
3+
SELECT 1
4+
FROM journey_pattern.scheduled_stop_point_in_journey_pattern
5+
WHERE journey_pattern_id = jp.journey_pattern_id
6+
);
7+
8+
DELETE FROM route.route r
9+
WHERE NOT EXISTS (
10+
SELECT 1
11+
FROM route.infrastructure_link_along_route
12+
WHERE route_id = r.route_id
13+
);
14+
15+
DELETE FROM route.route r
16+
WHERE NOT EXISTS (
17+
SELECT 1
18+
FROM journey_pattern.journey_pattern
19+
WHERE on_route_id = r.route_id
20+
);
21+
22+
DELETE FROM route.line l
23+
WHERE NOT EXISTS (
24+
SELECT 1
25+
FROM route.route
26+
WHERE on_line_id = l.line_id
27+
);

0 commit comments

Comments
 (0)