1 defmodule Pleroma.Repo.Migrations.FillRecipientsInActivities do
3 alias Pleroma.{Repo, Activity}
6 max = Repo.aggregate(Activity, :max, :id)
8 IO.puts("#{max} activities")
9 chunks = 0..(round(max / 10_000))
11 Enum.each(chunks, fn (i) ->
15 update activities set recipients = array(select jsonb_array_elements_text(data->'to')) where id > #{min} and id <= #{max};