summaryrefslogtreecommitdiff
path: root/migrations
diff options
context:
space:
mode:
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;