]> Untitled Git - lemmy.git/blob - server/migrations/2020-03-26-192410_add_activitypub_tables/up.sql
routes.api: fix get_captcha endpoint (#1135)
[lemmy.git] / server / migrations / 2020-03-26-192410_add_activitypub_tables / up.sql
1 -- The Activitypub activity table
2 -- All user actions must create a row here.
3 create table activity (
4   id serial primary key,
5   user_id int references user_ on update cascade on delete cascade not null, -- Ensures that the user is set up here.
6   data jsonb not null,
7   local boolean not null default true,
8   published timestamp not null default now(),
9   updated timestamp
10 );
11
12 -- Making sure that id is unique
13 create unique index idx_activity_unique_apid on activity ((data ->> 'id'::text));
14
15 -- Add federation columns to the two actor tables
16 alter table user_ 
17 -- TODO uniqueness constraints should be added on these 3 columns later
18 add column actor_id character varying(255) not null default 'http://fake.com', -- This needs to be checked and updated in code, building from the site url if local
19 add column bio text, -- not on community, already has description
20 add column local boolean not null default true,
21 add column private_key text, -- These need to be generated from code
22 add column public_key text,
23 add column last_refreshed_at timestamp not null default now() -- Used to re-fetch federated actor periodically
24 ;
25
26 -- Community
27 alter table community 
28 add column actor_id character varying(255) not null default 'http://fake.com', -- This needs to be checked and updated in code, building from the site url if local
29 add column local boolean not null default true,
30 add column private_key text, -- These need to be generated from code
31 add column public_key text,
32 add column last_refreshed_at timestamp not null default now() -- Used to re-fetch federated actor periodically
33 ;
34
35 -- Don't worry about rebuilding the views right now.
36