]> Untitled Git - lemmy.git/blob - migrations/2019-10-19-052737_create_user_mention/up.sql
routes.api: fix get_captcha endpoint (#1135)
[lemmy.git] / migrations / 2019-10-19-052737_create_user_mention / up.sql
1 create table user_mention (
2   id serial primary key,
3   recipient_id int references user_ on update cascade on delete cascade not null,
4   comment_id int references comment on update cascade on delete cascade not null,
5   read boolean default false not null,
6   published timestamp not null default now(),
7   unique(recipient_id, comment_id)
8 );
9
10 create view user_mention_view as
11 select 
12     c.id,
13     um.id as user_mention_id,
14     c.creator_id,
15     c.post_id,
16     c.parent_id,
17     c.content,
18     c.removed,
19     um.read,
20     c.published,
21     c.updated,
22     c.deleted,
23     c.community_id,
24     c.banned,
25     c.banned_from_community,
26     c.creator_name,
27     c.score,
28     c.upvotes,
29     c.downvotes,
30     c.user_id,
31     c.my_vote,
32     c.saved,
33     um.recipient_id
34 from user_mention um, comment_view c
35 where um.comment_id = c.id;