diff options
| author | Alexander Strizhakov <alex.strizhakov@gmail.com> | 2019-07-14 13:29:31 +0000 | 
|---|---|---|
| committer | kaniini <ariadne@dereferenced.org> | 2019-07-14 13:29:31 +0000 | 
| commit | e7c39b7ac8f0462ab563d3cf51f24c76feab0e8d (patch) | |
| tree | c1de518adad818122896794f646c679db91f5538 /priv/repo/migrations | |
| parent | 9f211838eca3793bac8bbb6b64f200a8a6c8d29f (diff) | |
| download | pleroma-e7c39b7ac8f0462ab563d3cf51f24c76feab0e8d.tar.gz pleroma-e7c39b7ac8f0462ab563d3cf51f24c76feab0e8d.zip | |
Feature/1072 muting notifications
Diffstat (limited to 'priv/repo/migrations')
| -rw-r--r-- | priv/repo/migrations/20190711042024_copy_muted_to_muted_notifications.exs | 24 | 
1 files changed, 24 insertions, 0 deletions
| diff --git a/priv/repo/migrations/20190711042024_copy_muted_to_muted_notifications.exs b/priv/repo/migrations/20190711042024_copy_muted_to_muted_notifications.exs new file mode 100644 index 000000000..50669902e --- /dev/null +++ b/priv/repo/migrations/20190711042024_copy_muted_to_muted_notifications.exs @@ -0,0 +1,24 @@ +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 | 
