]> Untitled Git - lemmy.git/blob - migrations/2019-02-27-170003_create_community/up.sql
routes.api: fix get_captcha endpoint (#1135)
[lemmy.git] / migrations / 2019-02-27-170003_create_community / up.sql
1 create table category (
2   id serial primary key,
3   name varchar(100) not null unique
4 );
5
6 insert into category (name) values
7 ('Discussion'),
8 ('Humor/Memes'),
9 ('Gaming'),
10 ('Movies'),
11 ('TV'),
12 ('Music'),
13 ('Literature'),
14 ('Comics'),
15 ('Photography'),
16 ('Art'),
17 ('Learning'),
18 ('DIY'),
19 ('Lifestyle'),
20 ('News'),
21 ('Politics'),
22 ('Society'),
23 ('Gender/Identity/Sexuality'),
24 ('Race/Colonisation'),
25 ('Religion'),
26 ('Science/Technology'),
27 ('Programming/Software'),
28 ('Health/Sports/Fitness'),
29 ('Porn'),
30 ('Places'),
31 ('Meta'),
32 ('Other');
33
34 create table community (
35   id serial primary key,
36   name varchar(20) not null unique,
37   title varchar(100) not null,
38   description text,
39   category_id int references category on update cascade on delete cascade not null,
40   creator_id int references user_ on update cascade on delete cascade not null,
41   removed boolean default false not null,
42   published timestamp not null default now(),
43   updated timestamp
44 );
45
46 create table community_moderator (
47   id serial primary key,
48   community_id int references community on update cascade on delete cascade not null,
49   user_id int references user_ on update cascade on delete cascade not null,
50   published timestamp not null default now(),
51   unique (community_id, user_id)
52 );
53
54 create table community_follower (
55   id serial primary key,
56   community_id int references community on update cascade on delete cascade not null,
57   user_id int references user_ on update cascade on delete cascade not null,
58   published timestamp not null default now(),
59   unique (community_id, user_id)
60 );
61
62 create table community_user_ban (
63   id serial primary key,
64   community_id int references community on update cascade on delete cascade not null,
65   user_id int references user_ on update cascade on delete cascade not null,
66   published timestamp not null default now(),
67   unique (community_id, user_id)
68 );
69
70 insert into community (name, title, category_id, creator_id) values ('main', 'The Default Community', 1, 1);
71
72 create table site (
73   id serial primary key,
74   name varchar(20) not null unique,
75   description text,
76   creator_id int references user_ on update cascade on delete cascade not null,
77   published timestamp not null default now(),
78   updated timestamp
79 );