summaryrefslogtreecommitdiff
path: root/migrations/6_genericize_access_control.sql
blob: c7727bfaed700bb7f590d8166714e4c2646e7ff3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
BEGIN;

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.id
    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;

COMMIT;