소스 검색

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
object-id-column
rinpatch 4 년 전
부모
커밋
ee88afb2e2
1개의 변경된 파일1개의 추가작업 그리고 12개의 파일을 삭제
  1. +1
    -12
      priv/repo/migrations/20190711042024_copy_muted_to_muted_notifications.exs

+ 1
- 12
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

불러오는 중...
취소
저장