]> Untitled Git - lemmy.git/blob - migrations/2019-03-03-163336_create_post/up.sql
Isomorphic docker (#1124)
[lemmy.git] / migrations / 2019-03-03-163336_create_post / up.sql
1 create table post (
2   id serial primary key,
3   name varchar(100) not null,
4   url text, -- These are both optional, a post can just have a title
5   body text,
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(),
11   updated timestamp
12 );
13
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)
21 );
22
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)
29 );
30
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)
37 );