]> Untitled Git - lemmy.git/blob - migrations/2019-04-11-144915_create_mod_views/up.sql
Isomorphic docker (#1124)
[lemmy.git] / migrations / 2019-04-11-144915_create_mod_views / up.sql
1 create view mod_remove_post_view as 
2 select mrp.*,
3 (select name from user_ u where mrp.mod_user_id = u.id) as mod_user_name,
4 (select name from post p where mrp.post_id = p.id) as post_name,
5 (select c.id from post p, community c where mrp.post_id = p.id and p.community_id = c.id) as community_id,
6 (select c.name from post p, community c where mrp.post_id = p.id and p.community_id = c.id) as community_name
7 from mod_remove_post mrp;
8
9 create view mod_lock_post_view as 
10 select mlp.*,
11 (select name from user_ u where mlp.mod_user_id = u.id) as mod_user_name,
12 (select name from post p where mlp.post_id = p.id) as post_name,
13 (select c.id from post p, community c where mlp.post_id = p.id and p.community_id = c.id) as community_id,
14 (select c.name from post p, community c where mlp.post_id = p.id and p.community_id = c.id) as community_name
15 from mod_lock_post mlp;
16
17 create view mod_remove_comment_view as 
18 select mrc.*,
19 (select name from user_ u where mrc.mod_user_id = u.id) as mod_user_name,
20 (select c.id from comment c where mrc.comment_id = c.id) as comment_user_id,
21 (select name from user_ u, comment c where mrc.comment_id = c.id and u.id = c.creator_id) as comment_user_name,
22 (select content from comment c where mrc.comment_id = c.id) as comment_content,
23 (select p.id from post p, comment c where mrc.comment_id = c.id and c.post_id = p.id) as post_id,
24 (select p.name from post p, comment c where mrc.comment_id = c.id and c.post_id = p.id) as post_name,
25 (select co.id from comment c, post p, community co where mrc.comment_id = c.id and c.post_id = p.id and p.community_id = co.id) as community_id, 
26 (select co.name from comment c, post p, community co where mrc.comment_id = c.id and c.post_id = p.id and p.community_id = co.id) as community_name
27 from mod_remove_comment mrc;
28
29 create view mod_remove_community_view as 
30 select mrc.*,
31 (select name from user_ u where mrc.mod_user_id = u.id) as mod_user_name,
32 (select c.name from community c where mrc.community_id = c.id) as community_name
33 from mod_remove_community mrc;
34
35 create view mod_ban_from_community_view as 
36 select mb.*,
37 (select name from user_ u where mb.mod_user_id = u.id) as mod_user_name,
38 (select name from user_ u where mb.other_user_id = u.id) as other_user_name,
39 (select name from community c where mb.community_id = c.id) as community_name
40 from mod_ban_from_community mb;
41
42 create view mod_ban_view as 
43 select mb.*,
44 (select name from user_ u where mb.mod_user_id = u.id) as mod_user_name,
45 (select name from user_ u where mb.other_user_id = u.id) as other_user_name
46 from mod_ban mb;
47
48 create view mod_add_community_view as 
49 select ma.*,
50 (select name from user_ u where ma.mod_user_id = u.id) as mod_user_name,
51 (select name from user_ u where ma.other_user_id = u.id) as other_user_name,
52 (select name from community c where ma.community_id = c.id) as community_name
53 from mod_add_community ma;
54
55 create view mod_add_view as 
56 select ma.*,
57 (select name from user_ u where ma.mod_user_id = u.id) as mod_user_name,
58 (select name from user_ u where ma.other_user_id = u.id) as other_user_name
59 from mod_add ma;