2 drop trigger refresh_private_message on private_message;
3 drop function refresh_private_message();
5 -- Drop the view and table
6 drop view private_message_view cascade;
7 drop table private_message;
9 -- Rebuild the old views
10 drop view user_view cascade;
11 create view user_view as
21 u.send_notifications_to_email,
23 (select count(*) from post p where p.creator_id = u.id) as number_of_posts,
24 (select coalesce(sum(score), 0) from post p, post_like pl where u.id = p.creator_id and p.id = pl.post_id) as post_score,
25 (select count(*) from comment c where c.creator_id = u.id) as number_of_comments,
26 (select coalesce(sum(score), 0) from comment c, comment_like cl where u.id = c.creator_id and c.id = cl.comment_id) as comment_score
29 create materialized view user_mview as select * from user_view;
31 create unique index idx_user_mview_id on user_mview (id);
34 alter table user_ drop column matrix_user_id;