X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=priv%2Frepo%2Fmigrations%2F20190711042024_copy_muted_to_muted_notifications.exs;h=bbd50204416a1482bafa1ae55de3f8186c8ca1a8;hb=refs%2Fheads%2Fdevelop;hp=50669902e57956be76b075c82b0d771bc6316152;hpb=196cad46f35a63c18d58cd5d982bc4e1f9b0d7c3;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 50669902e..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,24 +1,11 @@ defmodule Pleroma.Repo.Migrations.CopyMutedToMutedNotifications do use Ecto.Migration - alias Pleroma.User def change do - query = - User.Query.build(%{ - local: true, - active: true, - order_by: :id - }) + execute("update users set info = '{}' where info is null") - 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