diff options
author | rinpatch <rinpatch@sdf.org> | 2020-03-07 13:51:28 +0300 |
---|---|---|
committer | rinpatch <rinpatch@sdf.org> | 2020-03-07 17:00:58 +0300 |
commit | 6cf1958b02303da4a50987fea351434f9f7dd2aa (patch) | |
tree | 94e963c13fad150f89327d728882c13a81762293 /priv/repo/migrations/20200307103755_fix_moderation_log_subjects.exs | |
parent | 474ef512df5c7833f29e6201c52238b5d561a785 (diff) | |
download | pleroma-6cf1958b02303da4a50987fea351434f9f7dd2aa.tar.gz pleroma-6cf1958b02303da4a50987fea351434f9f7dd2aa.zip |
moderation log: fix improperly migrated data
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
Diffstat (limited to 'priv/repo/migrations/20200307103755_fix_moderation_log_subjects.exs')
-rw-r--r-- | priv/repo/migrations/20200307103755_fix_moderation_log_subjects.exs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/priv/repo/migrations/20200307103755_fix_moderation_log_subjects.exs b/priv/repo/migrations/20200307103755_fix_moderation_log_subjects.exs new file mode 100644 index 000000000..d1c8539e1 --- /dev/null +++ b/priv/repo/migrations/20200307103755_fix_moderation_log_subjects.exs @@ -0,0 +1,9 @@ +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 |