Fix a migration wiping user info of users that don't have any mutes
And introduce safe_jsonb_set
This commit is contained in:
parent
724f611b0e
commit
39e996528c
5 changed files with 30 additions and 8 deletions
|
|
@ -28,7 +28,7 @@ defmodule Mix.Tasks.Pleroma.Database do
|
|||
Logger.info("Removing embedded objects")
|
||||
|
||||
Repo.query!(
|
||||
"update activities set data = jsonb_set(data, '{object}'::text[], data->'object'->'id') where data->'object'->>'id' is not null;",
|
||||
"update activities set data = safe_jsonb_set(data, '{object}'::text[], data->'object'->'id') where data->'object'->>'id' is not null;",
|
||||
[],
|
||||
timeout: :infinity
|
||||
)
|
||||
|
|
@ -126,7 +126,7 @@ defmodule Mix.Tasks.Pleroma.Database do
|
|||
set: [
|
||||
data:
|
||||
fragment(
|
||||
"jsonb_set(?, '{likes}', '[]'::jsonb, true)",
|
||||
"safe_jsonb_set(?, '{likes}', '[]'::jsonb, true)",
|
||||
object.data
|
||||
)
|
||||
]
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -727,7 +727,7 @@ defmodule Pleroma.User do
|
|||
set: [
|
||||
info:
|
||||
fragment(
|
||||
"jsonb_set(?, '{note_count}', ((?->>'note_count')::int + 1)::varchar::jsonb, true)",
|
||||
"safe_jsonb_set(?, '{note_count}', ((?->>'note_count')::int + 1)::varchar::jsonb, true)",
|
||||
u.info,
|
||||
u.info
|
||||
)
|
||||
|
|
@ -748,7 +748,7 @@ defmodule Pleroma.User do
|
|||
set: [
|
||||
info:
|
||||
fragment(
|
||||
"jsonb_set(?, '{note_count}', (greatest(0, (?->>'note_count')::int - 1))::varchar::jsonb, true)",
|
||||
"safe_jsonb_set(?, '{note_count}', (greatest(0, (?->>'note_count')::int - 1))::varchar::jsonb, true)",
|
||||
u.info,
|
||||
u.info
|
||||
)
|
||||
|
|
@ -818,7 +818,7 @@ defmodule Pleroma.User do
|
|||
set: [
|
||||
info:
|
||||
fragment(
|
||||
"jsonb_set(?, '{follower_count}', ?::varchar::jsonb, true)",
|
||||
"safe_jsonb_set(?, '{follower_count}', ?::varchar::jsonb, true)",
|
||||
u.info,
|
||||
s.count
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue