summaryrefslogtreecommitdiff
path: root/migrations
diff options
context:
space:
mode:
authorMatthias Andreas Benkard <code@mail.matthias.benkard.de>2012-08-18 17:49:46 +0200
committerMatthias Andreas Benkard <code@mail.matthias.benkard.de>2012-08-18 17:49:46 +0200
commit28c046e169c5874ce066228e7f3658d02317c216 (patch)
treedba7d84bbfbf7173632b70c9e89fc80282ebe3d6 /migrations
parent573113dfb99e4d6eb6086b53dee1afcb845c18a9 (diff)
Schema: Genericize access control.
Diffstat (limited to 'migrations')
-rw-r--r--migrations/6_genericize_access_control.sql14
1 files changed, 14 insertions, 0 deletions
diff --git a/migrations/6_genericize_access_control.sql b/migrations/6_genericize_access_control.sql
new file mode 100644
index 0000000..b415d5b
--- /dev/null
+++ b/migrations/6_genericize_access_control.sql
@@ -0,0 +1,14 @@
+ALTER TABLE lazychat_targets RENAME TO post_targets;
+
+CREATE VIEW user_visible_posts AS
+ SELECT eur.user, t.message
+ FROM effective_user_roles eur, post_targets t
+ WHERE t.target = eur.role
+ UNION
+ SELECT m.owner, m.message
+ FROM posts m;
+
+CREATE OR REPLACE VIEW user_visible_lazychat_messages AS
+ SELECT uvp.user, uvp.message
+ FROM user_visible_posts uvp
+ INNER JOIN lazychat_messages lm ON lm.id = uvp.message;