2024-07-17 16:37:40 +00:00
|
|
|
CREATE TABLE IF NOT EXISTS mod_log (
|
2024-08-04 16:31:19 +00:00
|
|
|
guild_id BIGINT UNSIGNED NOT NULL PRIMARY KEY,
|
2024-07-17 16:37:40 +00:00
|
|
|
channel_id BIGINT UNSIGNED NOT NULL,
|
|
|
|
is_enabled BOOLEAN NOT NULL DEFAULT TRUE,
|
|
|
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
|
|
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
|
|
|
|
);
|
|
|
|
|
2024-07-18 15:26:36 +00:00
|
|
|
CREATE TABLE IF NOT EXISTS cases (
|
2024-07-17 16:37:40 +00:00
|
|
|
id SERIAL PRIMARY KEY,
|
2024-07-18 15:26:36 +00:00
|
|
|
guild_id BIGINT UNSIGNED NOT NULL,
|
|
|
|
case_number INT UNSIGNED NOT NULL,
|
|
|
|
target_id BIGINT UNSIGNED NOT NULL,
|
|
|
|
moderator_id BIGINT UNSIGNED NOT NULL,
|
|
|
|
action_type ENUM(
|
2024-07-17 16:37:40 +00:00
|
|
|
'WARN',
|
|
|
|
'TIMEOUT',
|
|
|
|
'UNTIMEOUT',
|
|
|
|
'KICK',
|
|
|
|
'BAN',
|
|
|
|
'UNBAN',
|
|
|
|
'SOFTBAN',
|
|
|
|
'TEMPBAN',
|
|
|
|
'NOTE',
|
|
|
|
'MUTE',
|
|
|
|
'UNMUTE',
|
|
|
|
'DEAFEN',
|
|
|
|
'UNDEAFEN'
|
2024-07-18 15:26:36 +00:00
|
|
|
) NOT NULL,
|
2024-07-17 16:37:40 +00:00
|
|
|
reason TEXT,
|
|
|
|
duration INT UNSIGNED, -- for timeouts
|
|
|
|
expires_at TIMESTAMP, -- for tempbans & mutes
|
2024-07-18 10:59:16 +00:00
|
|
|
modlog_message_id BIGINT UNSIGNED,
|
|
|
|
is_closed BOOLEAN NOT NULL DEFAULT FALSE, -- to indicate if the case is closed
|
2024-07-17 16:37:40 +00:00
|
|
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
|
|
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
2024-07-18 10:59:16 +00:00
|
|
|
UNIQUE KEY unique_case (guild_id, case_number)
|
2024-07-17 16:37:40 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
|
2024-08-01 14:09:54 +00:00
|
|
|
CREATE OR REPLACE INDEX idx_cases_guild_id ON cases(guild_id);
|
|
|
|
CREATE OR REPLACE INDEX idx_cases_target_id ON cases(target_id);
|
|
|
|
CREATE OR REPLACE INDEX idx_cases_moderator_id ON cases(moderator_id);
|
|
|
|
CREATE OR REPLACE INDEX idx_cases_action_type ON cases(action_type);
|