Merge branch 'fix/bad-migration' into 'develop'
Fix muted notification migration only working with a schema See merge request pleroma/pleroma!1803
This commit is contained in:
commit
25cffffaf1
@ -1,19 +1,8 @@
|
|||||||
defmodule Pleroma.Repo.Migrations.CopyMutedToMutedNotifications do
|
defmodule Pleroma.Repo.Migrations.CopyMutedToMutedNotifications do
|
||||||
use Ecto.Migration
|
use Ecto.Migration
|
||||||
import Ecto.Query
|
|
||||||
alias Pleroma.User
|
alias Pleroma.User
|
||||||
|
|
||||||
def change do
|
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)
|
execute("update users set info = jsonb_set(info, '{muted_notifications}', info->'mutes', true) where local = true")
|
||||||
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
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user