Skip to content

Open Infrastructure Map, a view of infrastructure data in OpenStreetMap

Move stats SQL to schema directory

Russ Garrett69d17370e81e
diff --git a/schema/prod-init.sql b/schema/prod-init.sql
index 25eca2e..f0b9ad7 100644
--- a/schema/prod-init.sql
+++ b/schema/prod-init.sql
@@ -9,4 +9,6 @@ GRANT SELECT ON ALL TABLES IN SCHEMA countries TO tegola;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO web_backend;
GRANT ALL ON SCHEMA countries TO web_backend;
-GRANT SELECT ON ALL TABLES IN SCHEMA countries TO web_backend;
\ No newline at end of file
+GRANT SELECT ON ALL TABLES IN SCHEMA countries TO web_backend;
+GRANT ALL ON SCHEMA stats TO web_backend;
+GRANT SELECT ON ALL TABLES IN SCHEMA stats TO web_backend;
\ No newline at end of file
diff --git a/web-backend/generate-stats.sql b/schema/stats.sql
similarity index 95%
rename from web-backend/generate-stats.sql
rename to schema/stats.sql
index 624180d..07d9abf 100644
--- a/web-backend/generate-stats.sql
+++ b/schema/stats.sql
@@ -1,3 +1,5 @@
+-- Stats schema used by the web backend:
+
CREATE SCHEMA stats;
CREATE TABLE stats.power_line (
@@ -28,7 +30,7 @@ CREATE TABLE stats.power_generator (
-----------------------------
-
+-- Queries used to update the stats schema:
INSERT INTO stats.power_line (time, country, voltage, length)
SELECT now() AS time, country_eez_sub."union" AS country, convert_voltage(voltage)::INTEGER AS voltage,