Add changelog entry for hashtag following
[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
9 if max do
10 IO.puts("#{max} activities")
11 chunks = 0..round(max / 10_000)
12
13 Enum.each(chunks, fn i ->
14 min = i * 10_000
15 max = min + 10_000
16
17 execute("""
18 update activities set actor = data->>'actor' where id > #{min} and id <= #{max};
19 """)
20 |> IO.inspect()
21 end)
22 end
23 end
24
25 def down do
26 end
27 end