]> Untitled Git - lemmy.git/blob - migrations/2019-03-05-233828_create_comment/up.sql
routes.api: fix get_captcha endpoint (#1135)
[lemmy.git] / migrations / 2019-03-05-233828_create_comment / up.sql
1 create table comment (
2   id serial primary key,
3   creator_id int references user_ on update cascade on delete cascade not null,
4   post_id int references post on update cascade on delete cascade not null,
5   parent_id int references comment on update cascade on delete cascade,
6   content text not null,
7   removed boolean default false not null,
8   read boolean default false not null,
9   published timestamp not null default now(),
10   updated timestamp
11 );
12
13 create table comment_like (
14   id serial primary key,
15   user_id int references user_ on update cascade on delete cascade not null,
16   comment_id int references comment on update cascade on delete cascade not null,
17   post_id int references post on update cascade on delete cascade not null,
18   score smallint not null, -- -1, or 1 for dislike, like, no row for no opinion
19   published timestamp not null default now(),
20   unique(comment_id, user_id)
21 );
22
23 create table comment_saved (
24   id serial primary key,
25   comment_id int references comment on update cascade on delete cascade not null,
26   user_id int references user_ on update cascade on delete cascade not null,
27   published timestamp not null default now(),
28   unique(comment_id, user_id)
29 );