diff options
author | kPherox <admin@mail.kr-kp.com> | 2019-10-29 19:16:34 +0900 |
---|---|---|
committer | kPherox <admin@mail.kr-kp.com> | 2019-10-29 19:22:34 +0900 |
commit | 5334190056b853dda57f16cbbaa230e8947821c6 (patch) | |
tree | 84cdfe178614a4ab331642d70067c7b64f2089d6 | |
parent | c2f2d7bcf66327b0eabf008f3819b374248c3ac2 (diff) | |
download | pleroma-5334190056b853dda57f16cbbaa230e8947821c6.tar.gz pleroma-5334190056b853dda57f16cbbaa230e8947821c6.zip |
Migrate missing follow requests
-rw-r--r-- | priv/repo/migrations/20191029101340_migrate_missing_follow_requests.exs | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/priv/repo/migrations/20191029101340_migrate_missing_follow_requests.exs b/priv/repo/migrations/20191029101340_migrate_missing_follow_requests.exs new file mode 100644 index 000000000..1b2666f3a --- /dev/null +++ b/priv/repo/migrations/20191029101340_migrate_missing_follow_requests.exs @@ -0,0 +1,35 @@ +defmodule Pleroma.Repo.Migrations.MigrateFollowingRelationships do + use Ecto.Migration + + def change do + execute(import_pending_follows_from_activities(), "") + end + + defp import_pending_follows_from_activities do + """ + INSERT INTO + following_relationships ( + follower_id, + following_id, + state, + inserted_at, + updated_at + ) + SELECT + followers.id, + following.id, + activities.data ->> 'state', + (activities.data ->> 'published') :: timestamp, + now() + FROM + activities + JOIN users AS followers ON (activities.actor = followers.ap_id) + JOIN users AS following ON (activities.data ->> 'object' = following.ap_id) + WHERE + activities.data ->> 'type' = 'Follow' + AND activities.data ->> 'state' = 'pending' + ORDER BY activities.updated_at DESC + ON CONFLICT DO NOTHING + """ + end +end |