Mercurial > gemma
diff schema/auth.sql @ 177:4e2451d561b1
Make schema for templates more realistic
A print template should be stored with name and timestamp and
the template itself will be any data to be interpreted as
a template file by a templating engine.
Delete relations in user_templates with their parents using CASCADE,
because user_templates is only an m:n-table.
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Tue, 17 Jul 2018 16:50:16 +0200 |
parents | 3f7053e53fa6 |
children | 382f631d8dd8 |
line wrap: on
line diff
--- a/schema/auth.sql Tue Jul 17 12:01:14 2018 +0200 +++ b/schema/auth.sql Tue Jul 17 16:50:16 2018 +0200 @@ -57,7 +57,7 @@ ALTER TABLE user_profiles ENABLE ROW LEVEL SECURITY; CREATE POLICY own_templates ON templates FOR SELECT TO waterway_user - USING (id IN(SELECT template_id FROM user_templates + USING (template_name IN(SELECT template_name FROM user_templates WHERE username = current_user)); ALTER TABLE templates ENABLE ROW LEVEL SECURITY; @@ -87,7 +87,7 @@ USING (country = current_user_country()); CREATE POLICY manage_templates ON templates FOR ALL TO waterway_admin - USING (id IN(SELECT template_id FROM user_templates ut + USING (template_name IN(SELECT template_name FROM user_templates ut JOIN user_profiles p ON ut.username = p.username WHERE p.country = current_user_country()));