From 936050257d7899202ed78c455247adcd076f60e8 Mon Sep 17 00:00:00 2001 From: Alex S Date: Wed, 10 Jul 2019 16:02:22 +0300 Subject: [PATCH] saving following_address for existing users --- ...add_following_address_from_source_data.exs | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 priv/repo/migrations/20190710125158_add_following_address_from_source_data.exs 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