X-Git-Url: https://git.squeep.com/?a=blobdiff_plain;f=priv%2Frepo%2Fmigrations%2F20190711042024_copy_muted_to_muted_notifications.exs;h=bbd50204416a1482bafa1ae55de3f8186c8ca1a8;hb=73609211a425922a5068d3912a36b82abe24e12c;hp=815d665494746ca75e984240c70662f5005609d0;hpb=a0d336a8283a15fc29ae88f0498d202d1bef3cce;p=akkoma diff --git a/priv/repo/migrations/20190711042024_copy_muted_to_muted_notifications.exs b/priv/repo/migrations/20190711042024_copy_muted_to_muted_notifications.exs index 815d66549..bbd502044 100644 --- a/priv/repo/migrations/20190711042024_copy_muted_to_muted_notifications.exs +++ b/priv/repo/migrations/20190711042024_copy_muted_to_muted_notifications.exs @@ -1,19 +1,11 @@ defmodule Pleroma.Repo.Migrations.CopyMutedToMutedNotifications do use Ecto.Migration - import Ecto.Query - alias Pleroma.User def change do - query = from(u in "users", where: fragment("not (?->'deactivated' @> 'true')", u.info), select: %{info: u.info}, where: u.local == true, order_by: u.id) - Pleroma.Repo.stream(query) - |> Enum.each(fn - %{info: %{mutes: mutes} = info} = user -> - info_cng = - Ecto.Changeset.cast(info, %{muted_notifications: mutes}, [:muted_notifications]) + execute("update users set info = '{}' where info is null") - Ecto.Changeset.change(user) - |> Ecto.Changeset.put_embed(:info, info_cng) - |> Pleroma.Repo.update() - end) + execute( + "update users set info = safe_jsonb_set(info, '{muted_notifications}', info->'mutes', true) where local = true" + ) end end