mark demolitions script
This commit is contained in:
parent
07d578cc9c
commit
880e8d6424
25
etl/mark_demolitions.sh
Normal file
25
etl/mark_demolitions.sh
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
psql -c "DROP TABLE IF EXISTS old_geometries;"
|
||||||
|
|
||||||
|
echo "Creating temporary table for geometries in the db not present in new data..."
|
||||||
|
psql -c "CREATE TABLE IF NOT EXISTS old_geometries (
|
||||||
|
source_id varchar(30) PRIMARY KEY,
|
||||||
|
geometry_geom geometry(GEOMETRY, 3857)
|
||||||
|
);"
|
||||||
|
|
||||||
|
echo "Find geometries in the db not present in new data..."
|
||||||
|
psql -c "INSERT INTO old_geometries ( source_id, geometry_geom )
|
||||||
|
SELECT source_id, geometry_geom
|
||||||
|
FROM geometries AS g
|
||||||
|
WHERE NOT EXISTS ( SELECT source_id
|
||||||
|
FROM release_geometries AS r
|
||||||
|
WHERE g.source_id = r.source_id);"
|
||||||
|
|
||||||
|
echo "Set each building's latest_demolish_date for today if linked geometry in the db not present in new data..."
|
||||||
|
psql -c "UPDATE buildings AS b
|
||||||
|
SET latest_demolish_date = CURRENT_DATE
|
||||||
|
WHERE b.source_id = g.source_id
|
||||||
|
AND source_id IN (SELECT source_id
|
||||||
|
FROM old_geometries AS g
|
||||||
|
);"
|
Loading…
Reference in New Issue
Block a user