1 -- Drop the materialized / built views
3 create view reply_view as
7 c2.creator_id as sender_id,
8 c.creator_id as recipient_id
10 inner join comment c2 on c.id = c2.parent_id
11 where c2.creator_id != c.creator_id
12 -- Do union where post is null
16 c.creator_id as sender_id,
17 p.creator_id as recipient_id
18 from comment c, post p
19 where c.post_id = p.id and c.parent_id is null and c.creator_id != p.creator_id
22 closereply.recipient_id
23 from comment_view cv, closereply
24 where closereply.id = cv.id