X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=priv%2Frepo%2Fmigrations%2F20190711042024_copy_muted_to_muted_notifications.exs;h=fc9bf70baf477ac311a6a7de488d67a15e0ab8d6;hb=a7ec08d8539f1cedc05a28a8934fa07959ee90dc;hp=815d665494746ca75e984240c70662f5005609d0;hpb=2411d092157e14caf45b3bc70cfc3b1c1478ac50;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..fc9bf70ba 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,9 @@ 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]) - - 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