CI: Bump lint stage to elixir-1.12
[akkoma] / priv / repo / migrations / 20171212164525_fill_recipients_in_activities.exs
1 defmodule Pleroma.Repo.Migrations.FillRecipientsInActivities do
2 use Ecto.Migration
3 alias Pleroma.{Repo, Activity}
4
5 def up do
6 max = Repo.aggregate(Activity, :max, :id)
7
8 if max do
9 IO.puts("#{max} activities")
10 chunks = 0..round(max / 10_000)
11
12 Enum.each(chunks, fn i ->
13 min = i * 10_000
14 max = min + 10_000
15
16 execute("""
17 update activities set recipients = array(select jsonb_array_elements_text(data->'to')) where id > #{min} and id <= #{max};
18 """)
19 |> IO.inspect()
20 end)
21 end
22 end
23
24 def down, do: :ok
25 end