]> Untitled Git - lemmy.git/blob - migrations/2020-03-26-192410_add_activitypub_tables/up.sql
Fixing broken SQL migration formatting. (#3800)
[lemmy.git] / 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.