summaryrefslogtreecommitdiffstats
path: root/server/migrations/2020-05-05-210233_add_activitypub_for_private_messages/up.sql
diff options
context:
space:
mode:
Diffstat (limited to 'server/migrations/2020-05-05-210233_add_activitypub_for_private_messages/up.sql')
-rw-r--r--server/migrations/2020-05-05-210233_add_activitypub_for_private_messages/up.sql25
1 files changed, 25 insertions, 0 deletions
diff --git a/server/migrations/2020-05-05-210233_add_activitypub_for_private_messages/up.sql b/server/migrations/2020-05-05-210233_add_activitypub_for_private_messages/up.sql
new file mode 100644
index 00000000..627be1f3
--- /dev/null
+++ b/server/migrations/2020-05-05-210233_add_activitypub_for_private_messages/up.sql
@@ -0,0 +1,25 @@
+alter table private_message
+add column ap_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
+;
+
+drop materialized view private_message_mview;
+drop view private_message_view;
+create view private_message_view as
+select
+pm.*,
+u.name as creator_name,
+u.avatar as creator_avatar,
+u.actor_id as creator_actor_id,
+u.local as creator_local,
+u2.name as recipient_name,
+u2.avatar as recipient_avatar,
+u2.actor_id as recipient_actor_id,
+u2.local as recipient_local
+from private_message pm
+inner join user_ u on u.id = pm.creator_id
+inner join user_ u2 on u2.id = pm.recipient_id;
+
+create materialized view private_message_mview as select * from private_message_view;
+
+create unique index idx_private_message_mview_id on private_message_mview (id);