Add option to modify HTTP pool size
[akkoma] / priv / repo / migrations / 20191029101340_migrate_missing_follow_requests.exs
1 defmodule Pleroma.Repo.Migrations.MigrateMissingFollowingRelationships do
2 use Ecto.Migration
3
4 def change do
5 execute(import_pending_follows_from_activities(), "")
6 end
7
8 defp import_pending_follows_from_activities do
9 """
10 INSERT INTO
11 following_relationships (
12 follower_id,
13 following_id,
14 state,
15 inserted_at,
16 updated_at
17 )
18 SELECT
19 followers.id,
20 following.id,
21 activities.data ->> 'state',
22 (activities.data ->> 'published') :: timestamp,
23 now()
24 FROM
25 activities
26 JOIN users AS followers ON (activities.actor = followers.ap_id)
27 JOIN users AS following ON (activities.data ->> 'object' = following.ap_id)
28 WHERE
29 activities.data ->> 'type' = 'Follow'
30 AND activities.data ->> 'state' = 'pending'
31 ORDER BY activities.updated_at DESC
32 ON CONFLICT DO NOTHING
33 """
34 end
35 end