changeset 1547:d4b7a6d054cd

Add table to store import configuration.
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Mon, 10 Dec 2018 15:55:10 +0100
parents b83928a8fadb
children ccf4fc8a6402
files schema/auth.sql schema/gemma.sql
diffstat 2 files changed, 21 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/schema/auth.sql	Mon Dec 10 15:31:27 2018 +0100
+++ b/schema/auth.sql	Mon Dec 10 15:55:10 2018 +0100
@@ -40,7 +40,7 @@
     users.templates, users.user_templates TO waterway_admin;
 GRANT INSERT, UPDATE, DELETE ON
     waterway.imports, waterway.import_logs, waterway.track_imports,
-    waterway.sounding_results
+    waterway.sounding_results, waterway.import_configuration
     TO waterway_admin;
 
 --
@@ -151,4 +151,13 @@
     FOR ALL TO waterway_admin
     USING (utm_covers(area));
 
+CREATE POLICY import_configuration_policy ON waterway.import_configuration
+    FOR ALL TO waterway_admin
+    USING (
+        users.current_user_country() = (
+            SELECT country FROM users.list_users lu
+            WHERE lu.username = waterway.import_configuration.username));
+
+ALTER table waterway.import_configuration ENABLE ROW LEVEL SECURITY;
+
 COMMIT;
--- a/schema/gemma.sql	Mon Dec 10 15:31:27 2018 +0100
+++ b/schema/gemma.sql	Mon Dec 10 15:55:10 2018 +0100
@@ -541,6 +541,17 @@
       waterway.sounding_results
       GROUP BY bottleneck_id) sr ON sr.bottleneck_id = bn.bottleneck_id
     ORDER BY objnam
+
+    CREATE TABLE import_configuration (
+        id int PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY,
+        username varchar NOT NULL
+            REFERENCES internal.user_profiles(username)
+                ON DELETE CASCADE
+                ON UPDATE CASCADE,
+        kind varchar NOT NULL,
+        cron varchar,
+        url  varchar
+    )
 ;
 
 -- Configure primary keys for geoserver views