pleroma/priv/repo/migrations/20190711042024_copy_muted_to_muted_notifications.exs

25 lines
590 B
Elixir
Raw Normal View History

2019-07-14 09:29:31 -04:00
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
})
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)
end
end