d4ac601da0c9d81c0a83f3be79a80035341b4d77
[akkoma] / priv / repo / migrations / 20171109114020_fill_actor_field.exs
1 defmodule Pleroma.Repo.Migrations.FillActorField do
2 use Ecto.Migration
3
4 alias Pleroma.{Repo, Activity}
5
6 def up do
7 max = Repo.aggregate(Activity, :max, :id)
8 IO.puts("#{max} activities")
9 chunks = 0..(round(max / 10_000))
10
11 Enum.each(chunks, fn (i) ->
12 min = i * 10_000
13 max = min + 10_000
14 IO.puts("Updating #{min}")
15 execute("""
16 update activities set actor = data->>'actor' where id > #{min} and id <= #{max};
17 """)
18 |> IO.inspect
19 end)
20 end
21
22 def down do
23 end
24 end
25