Merge branch 'feature/1072-muting-notifications' into 'develop'
[akkoma] / priv / repo / migrations / 20190711042024_copy_muted_to_muted_notifications.exs
1 defmodule Pleroma.Repo.Migrations.CopyMutedToMutedNotifications do
2 use Ecto.Migration
3 alias Pleroma.User
4
5 def change do
6 query =
7 User.Query.build(%{
8 local: true,
9 active: true,
10 order_by: :id
11 })
12
13 Pleroma.Repo.stream(query)
14 |> Enum.each(fn
15 %{info: %{mutes: mutes} = info} = user ->
16 info_cng =
17 Ecto.Changeset.cast(info, %{muted_notifications: mutes}, [:muted_notifications])
18
19 Ecto.Changeset.change(user)
20 |> Ecto.Changeset.put_embed(:info, info_cng)
21 |> Pleroma.Repo.update()
22 end)
23 end
24 end