logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma git clone https://anongit.hacktivis.me/git/pleroma.git/

20171109114020_fill_actor_field.exs (695B)


  1. # Pleroma: A lightweight social networking server
  2. # Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
  3. # SPDX-License-Identifier: AGPL-3.0-only
  4. defmodule Pleroma.Repo.Migrations.FillActorField do
  5. use Ecto.Migration
  6. alias Pleroma.{Repo, Activity}
  7. def up do
  8. max = Repo.aggregate(Activity, :max, :id)
  9. if max do
  10. IO.puts("#{max} activities")
  11. chunks = 0..round(max / 10_000)
  12. Enum.each(chunks, fn i ->
  13. min = i * 10_000
  14. max = min + 10_000
  15. execute("""
  16. update activities set actor = data->>'actor' where id > #{min} and id <= #{max};
  17. """)
  18. |> IO.inspect()
  19. end)
  20. end
  21. end
  22. def down do
  23. end
  24. end