diff options
| author | rinpatch <rinpatch@sdf.org> | 2019-10-06 17:53:03 +0300 | 
|---|---|---|
| committer | rinpatch <rinpatch@sdf.org> | 2019-10-06 18:20:24 +0300 | 
| commit | e442180d111258a0131aaef0e84e621518462455 (patch) | |
| tree | cdee557df1822b9a8dd889e53c9e8408a0e2ed16 | |
| parent | a0d336a8283a15fc29ae88f0498d202d1bef3cce (diff) | |
| download | pleroma-e442180d111258a0131aaef0e84e621518462455.tar.gz pleroma-e442180d111258a0131aaef0e84e621518462455.zip | |
Fix muted notification migration only working with a schema
Should also improve performance. I tested it on my local DB, but if
anyone has a backup of <=1.0 db they can test this on, please do
| -rw-r--r-- | priv/repo/migrations/20190711042024_copy_muted_to_muted_notifications.exs | 13 | 
1 files changed, 1 insertions, 12 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 index 815d66549..b717cab2e 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,8 @@  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 = jsonb_set(info, '{muted_notifications}', info->'mutes', true) where local = true")    end  end | 
