From: Alex S Date: Wed, 10 Jul 2019 13:02:22 +0000 (+0300) Subject: saving following_address for existing users X-Git-Url: https://git.squeep.com/?a=commitdiff_plain;h=936050257d7899202ed78c455247adcd076f60e8;p=akkoma saving following_address for existing users --- diff --git a/priv/repo/migrations/20190710125158_add_following_address_from_source_data.exs b/priv/repo/migrations/20190710125158_add_following_address_from_source_data.exs new file mode 100644 index 000000000..779aa382e --- /dev/null +++ b/priv/repo/migrations/20190710125158_add_following_address_from_source_data.exs @@ -0,0 +1,20 @@ +defmodule Pleroma.Repo.Migrations.AddFollowingAddressFromSourceData do + use Ecto.Migration + import Ecto.Query + alias Pleroma.User + + def change do + query = + User.external_users_query() + |> select([u], struct(u, [:id, :ap_id, :info])) + + Pleroma.Repo.stream(query) + |> Enum.each(fn + %{info: %{source_data: source_data}} = user -> + Ecto.Changeset.cast(user, %{following_address: source_data["following"]}, [ + :following_address + ]) + |> Pleroma.Repo.update() + end) + end +end