Fix a migration wiping user info of users that don't have any mutes

And introduce safe_jsonb_set
This commit is contained in:
rinpatch 2019-10-18 14:11:30 +03:00
commit 39e996528c
5 changed files with 30 additions and 8 deletions

View file

@ -181,7 +181,7 @@ defmodule Pleroma.Object do
data:
fragment(
"""
jsonb_set(?, '{repliesCount}',
safe_jsonb_set(?, '{repliesCount}',
(coalesce((?->>'repliesCount')::int, 0) + 1)::varchar::jsonb, true)
""",
o.data,
@ -204,7 +204,7 @@ defmodule Pleroma.Object do
data:
fragment(
"""
jsonb_set(?, '{repliesCount}',
safe_jsonb_set(?, '{repliesCount}',
(greatest(0, (?->>'repliesCount')::int - 1))::varchar::jsonb, true)
""",
o.data,