forked from mirrors/pronouns.cc
31 lines
1.3 KiB
MySQL
31 lines
1.3 KiB
MySQL
|
-- 2023-12-27: Add moderation log
|
||
|
|
||
|
-- +migrate Up
|
||
|
|
||
|
create table audit_log (
|
||
|
id bigint primary key,
|
||
|
-- the target user of this action
|
||
|
-- this is *not* a foreign key. if the user is deleted the audit log entry should stay, just showing as "deleted user <id>"
|
||
|
target_user_id bigint not null,
|
||
|
-- the target member of this action
|
||
|
target_member_id bigint,
|
||
|
-- the moderator that took this action
|
||
|
-- as with target_user_id, the audit log entry should not be deleted if the moderator's account is.
|
||
|
moderator_id bigint not null,
|
||
|
-- the report this was in response to. may be null if this action was taken by a moderator not responding to a report.
|
||
|
report_id integer references reports (id) on delete set null,
|
||
|
|
||
|
-- the reason for this action. always set, but may be 'None' if the action taken was 'ignore'.
|
||
|
reason text not null default 'None',
|
||
|
action_taken text not null, -- enum, currently: 'ignore', 'warn', 'suspend'
|
||
|
cleared_data jsonb null -- backup of the cleared data. may be null if no data was cleared
|
||
|
);
|
||
|
|
||
|
create index audit_log_target_user_idx on audit_log (target_user_id);
|
||
|
create index audit_log_target_member_idx on audit_log (target_member_id);
|
||
|
create index audit_log_moderator_idx on audit_log (moderator_id);
|
||
|
|
||
|
-- +migrate Down
|
||
|
|
||
|
drop table audit_log;
|