diff options
author | Dessalines <tyhou13@gmx.com> | 2020-04-03 00:12:05 -0400 |
---|---|---|
committer | Dessalines <tyhou13@gmx.com> | 2020-04-03 00:12:05 -0400 |
commit | 9197b39ed6f19b536510318b5446ec2ebb303396 (patch) | |
tree | 498b8b147afb7be11bc2b8e2fce52bb4eaafb309 /server/migrations | |
parent | 32b0275257053d2a7ebc696bae075f5918910d48 (diff) |
Federation DB Changes.
- Creating an activity table.
- Adding some federation-related columns to the user_ and community
tables.
- Generating the actor_id and keys in code, updating the tables.
Diffstat (limited to 'server/migrations')
-rw-r--r-- | server/migrations/2020-03-26-192410_add_activitypub_tables/down.sql | 16 | ||||
-rw-r--r-- | server/migrations/2020-03-26-192410_add_activitypub_tables/up.sql | 36 |
2 files changed, 52 insertions, 0 deletions
diff --git a/server/migrations/2020-03-26-192410_add_activitypub_tables/down.sql b/server/migrations/2020-03-26-192410_add_activitypub_tables/down.sql new file mode 100644 index 00000000..b1710623 --- /dev/null +++ b/server/migrations/2020-03-26-192410_add_activitypub_tables/down.sql @@ -0,0 +1,16 @@ +drop table activity; + +alter table user_ +drop column actor_id, +drop column private_key, +drop column public_key, +drop column bio, +drop column local, +drop column last_refreshed_at; + +alter table community +drop column actor_id, +drop column private_key, +drop column public_key, +drop column local, +drop column last_refreshed_at; diff --git a/server/migrations/2020-03-26-192410_add_activitypub_tables/up.sql b/server/migrations/2020-03-26-192410_add_activitypub_tables/up.sql new file mode 100644 index 00000000..8fe3b8ed --- /dev/null +++ b/server/migrations/2020-03-26-192410_add_activitypub_tables/up.sql @@ -0,0 +1,36 @@ +-- The Activitypub activity table +-- All user actions must create a row here. +create table activity ( + id serial primary key, + user_id int references user_ on update cascade on delete cascade not null, -- Ensures that the user is set up here. + data jsonb not null, + local boolean not null default true, + published timestamp not null default now(), + updated timestamp +); + +-- Making sure that id is unique +create unique index idx_activity_unique_apid on activity ((data ->> 'id'::text)); + +-- Add federation columns to the two actor tables +alter table user_ +-- TODO uniqueness constraints should be added on these 3 columns later +add column actor_id character varying(255) not null default 'changeme', -- This needs to be checked and updated in code, building from the site url if local +add column bio text, -- not on community, already has description +add column local boolean not null default true, +add column private_key text, -- These need to be generated from code +add column public_key text, +add column last_refreshed_at timestamp not null default now() -- Used to re-fetch federated actor periodically +; + +-- Community +alter table community +add column actor_id character varying(255) not null default 'changeme', -- This needs to be checked and updated in code, building from the site url if local +add column local boolean not null default true, +add column private_key text, -- These need to be generated from code +add column public_key text, +add column last_refreshed_at timestamp not null default now() -- Used to re-fetch federated actor periodically +; + +-- Don't worry about rebuilding the views right now. + |