· 4 years ago · Mar 01, 2021, 04:38 PM
1create table if not exists news
2(
3 news_id serial not null
4 constraint news_pkey
5 primary key,
6 url text not null,
7 title text not null,
8 description text not null,
9 summary text,
10 picture_url text,
11 sent boolean default false
12);
13
14create unique index if not exists news_description_uindex
15 on news (url);
16
17create table if not exists "user"
18(
19 user_id integer not null
20 constraint user_pkey
21 primary key,
22 lang text not null,
23 status text not null
24);
25
26alter table "user" owner to htkexrsn;
27
28create table if not exists channel
29(
30 channel_id numeric(20,1) not null
31 constraint channel_pkey
32 primary key,
33 reactions boolean not null,
34 comments boolean not null,
35 "user" integer not null
36 constraint fk_channel__user
37 references "user"
38 on delete cascade
39);
40
41alter table channel owner to htkexrsn;
42
43create index if not exists idx_channel__user
44 on channel ("user");
45
46create table if not exists post
47(
48 post_id serial not null
49 constraint post_pkey
50 primary key,
51 message_id integer not null,
52 channel numeric(20,1) not null
53 constraint fk_post__channel
54 references channel
55 on delete cascade,
56 text text not null
57);
58
59alter table post owner to htkexrsn;
60
61create index if not exists idx_post__channel
62 on post (channel);
63
64create table if not exists reaction
65(
66 reaction_type text not null,
67 post integer not null
68 constraint fk_reaction__post
69 references post
70 on delete cascade,
71 "user" integer not null
72 constraint fk_reaction__user
73 references "user"
74 on delete cascade,
75 constraint reaction_pkey
76 primary key (post, "user")
77);
78
79alter table reaction owner to htkexrsn;
80
81create index if not exists idx_reaction__user
82 on reaction ("user");
83