3 name varchar(100) not null,
4 url text, -- These are both optional, a post can just have a title
6 creator_id int references user_ on update cascade on delete cascade not null,
7 community_id int references community on update cascade on delete cascade not null,
8 removed boolean default false not null,
9 locked boolean default false not null,
10 published timestamp not null default now(),
14 create table post_like (
15 id serial primary key,
16 post_id int references post on update cascade on delete cascade not null,
17 user_id int references user_ 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(post_id, user_id)
23 create table post_saved (
24 id serial primary key,
25 post_id int references post 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(post_id, user_id)
31 create table post_read (
32 id serial primary key,
33 post_id int references post on update cascade on delete cascade not null,
34 user_id int references user_ on update cascade on delete cascade not null,
35 published timestamp not null default now(),
36 unique(post_id, user_id)