diff schema/auth.sql @ 345:b97b3172c61a

Add staging feature to more tables Added tables currently only have limited visibility for waterway_user but not yet policies for write access.
author Tom Gottfried <tom@intevation.de>
date Mon, 06 Aug 2018 15:19:05 +0200
parents 363983d5c567
children fe87457a05d7
line wrap: on
line diff
--- a/schema/auth.sql	Mon Aug 06 14:52:04 2018 +0200
+++ b/schema/auth.sql	Mon Aug 06 15:19:05 2018 +0200
@@ -54,14 +54,17 @@
 --
 
 -- Staging area
-CREATE FUNCTION create_hide_staging_policy()
-    RETURNS void
-AS $$
+DO LANGUAGE plpgsql
+$$
 DECLARE the_table varchar;
 BEGIN
     FOREACH the_table IN ARRAY ARRAY[
-        'bottlenecks', 'sounding_results']
-    -- TODO: add all relevant tables here
+        'gauge_measurements',
+        'sections_stretches',
+        'waterway_profiles',
+        'fairway_dimensions',
+        'bottlenecks',
+        'sounding_results']
     LOOP
         EXECUTE format('CREATE POLICY hide_staging ON waterway.%I '
             'FOR SELECT TO waterway_user USING (staging_done)', the_table);
@@ -69,10 +72,7 @@
             the_table);
     END LOOP;
 END;
-$$
-LANGUAGE plpgsql;
-SELECT create_hide_staging_policy();
-DROP FUNCTION create_hide_staging_policy;
+$$;
 
 CREATE POLICY user_templates ON users.user_templates FOR ALL TO waterway_user
     USING (username IN(SELECT username FROM users.list_users));