mirror of
https://akkoma.dev/AkkomaGang/akkoma.git
synced 2024-12-18 23:59:34 +00:00
6cf1958b02
Some of the actions used to have a user map as a subject, which was then changed to an array of user maps. However instead of migrating old data there was just a hack to transform it every time, moreover this hack didn't include all possible actions, which resulted in crashes. This commit fixes the crashes by introducing a proper database migration for old data. Closes #1606
10 lines
376 B
Elixir
10 lines
376 B
Elixir
defmodule Pleroma.Repo.Migrations.FixModerationLogSubjects do
|
|
use Ecto.Migration
|
|
|
|
def change do
|
|
execute(
|
|
"update moderation_log set data = safe_jsonb_set(data, '{subject}', safe_jsonb_set('[]'::jsonb, '{0}', data->'subject')) where jsonb_typeof(data->'subject') != 'array' and data->>'action' = ANY('{revoke,grant,activate,deactivate,delete}');"
|
|
)
|
|
end
|
|
end
|