diff --git a/migrations/2021-05-15-212923_misc/down.sql b/migrations/2021-05-15-212923_badges/down.sql similarity index 100% rename from migrations/2021-05-15-212923_misc/down.sql rename to migrations/2021-05-15-212923_badges/down.sql diff --git a/migrations/2021-05-15-212923_misc/up.sql b/migrations/2021-05-15-212923_badges/up.sql similarity index 100% rename from migrations/2021-05-15-212923_misc/up.sql rename to migrations/2021-05-15-212923_badges/up.sql diff --git a/migrations/2021-05-30-010200_firehose/up.sql b/migrations/2021-05-30-010200_firehose/up.sql index bfc5e3c6cc..40302a1e21 100644 --- a/migrations/2021-05-30-010200_firehose/up.sql +++ b/migrations/2021-05-30-010200_firehose/up.sql @@ -10,25 +10,6 @@ CREATE TABLE firehose_entries ( token VARCHAR(32) NOT NULL, -- The type of the event - -- DO NOT REORDER. - -- event_type ENUM( - -- 'not-set', - -- 'user_sign_up', - -- 'tts_model_upload_started', - -- 'tts_model_upload_completed', - -- 'tts_inference_started', - -- 'tts_inference_completed', - -- 'w2l_template_upload_started', - -- 'w2l_template_upload_completed', - -- 'w2l_inference_started', - -- 'w2l_inference_completed', - -- 'twitter_mention', - -- 'twitter_retweet', - -- 'discord_join', - -- 'discord_message', - -- 'twitch_subscribe', - -- 'twitch_follow' - -- ) NOT NULL DEFAULT 'not-set', event_type VARCHAR(32) NOT NULL, -- The target user diff --git a/migrations/2021-06-09-010200_ip_bans/down.sql b/migrations/2021-06-09-010200_ip_bans/down.sql new file mode 100644 index 0000000000..05e576cc5d --- /dev/null +++ b/migrations/2021-06-09-010200_ip_bans/down.sql @@ -0,0 +1,5 @@ +-- noinspection SqlDialectInspectionForFile +-- noinspection SqlNoDataSourceInspectionForFile +-- noinspection SqlResolveForFile + +drop table ip_address_bans; diff --git a/migrations/2021-06-09-010200_ip_bans/up.sql b/migrations/2021-06-09-010200_ip_bans/up.sql new file mode 100644 index 0000000000..8b285e9914 --- /dev/null +++ b/migrations/2021-06-09-010200_ip_bans/up.sql @@ -0,0 +1,37 @@ +-- noinspection SqlDialectInspectionForFile +-- noinspection SqlNoDataSourceInspectionForFile +-- noinspection SqlResolveForFile + +CREATE TABLE ip_address_bans ( + -- Not used for anything except replication. + id BIGINT(20) NOT NULL AUTO_INCREMENT, + + -- The IP address to ban + ip_address VARCHAR(40) DEFAULT NULL, + + -- Mod who created or last edited the ban. + mod_user_token VARCHAR(32) NOT NULL, + + -- Maybe the target user. + maybe_target_user_token VARCHAR(32) DEFAULT NULL, + + -- Optional notes about the ban. + notes TEXT DEFAULT NULL, + + -- Moderator can set an expire time (optional). + -- If not set, the ban is indefinite + expires_at TIMESTAMP DEFAULT NULL, + + created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + + -- If deleted, the ban is removed. + deleted_at TIMESTAMP DEFAULT NULL, + + -- INDICES -- + PRIMARY KEY (id), + UNIQUE KEY (ip_address), + KEY fk_mod_user_token (mod_user_token), + KEY fk_maybe_target_user_token (maybe_target_user_token) + +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; diff --git a/migrations/2021-06-09-010300_mod_audit_log/down.sql b/migrations/2021-06-09-010300_mod_audit_log/down.sql new file mode 100644 index 0000000000..72523365cb --- /dev/null +++ b/migrations/2021-06-09-010300_mod_audit_log/down.sql @@ -0,0 +1,5 @@ +-- noinspection SqlDialectInspectionForFile +-- noinspection SqlNoDataSourceInspectionForFile +-- noinspection SqlResolveForFile + +drop table moderator_audit_log_entries; \ No newline at end of file diff --git a/migrations/2021-06-09-010300_mod_audit_log/up.sql b/migrations/2021-06-09-010300_mod_audit_log/up.sql new file mode 100644 index 0000000000..ca30b2650a --- /dev/null +++ b/migrations/2021-06-09-010300_mod_audit_log/up.sql @@ -0,0 +1,38 @@ +-- noinspection SqlDialectInspectionForFile +-- noinspection SqlNoDataSourceInspectionForFile +-- noinspection SqlResolveForFile + +CREATE TABLE moderator_audit_logs_entries ( + -- Not used for anything except replication. + id BIGINT(20) NOT NULL AUTO_INCREMENT, + + -- Visible "primary key" + token VARCHAR(32) NOT NULL, + + -- The type of the event (ban, delete, etc.) + event_type VARCHAR(32) NOT NULL, + + -- The target user + maybe_target_user_token VARCHAR(32) DEFAULT NULL, + + -- The target "entity", which varies by event type. + -- eg. a model token or template token + maybe_target_entity_token VARCHAR(32) DEFAULT NULL, + + -- If an IP was banned, we record it here. + maybe_target_ip_address VARCHAR(40) DEFAULT NULL, + + -- Optional mod-specified notes. + optional_notes TEXT DEFAULT NULL, + + created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + + -- INDICES -- + PRIMARY KEY (id), + UNIQUE KEY (token), + KEY fk_maybe_target_user_token (maybe_target_user_token), + KEY fk_maybe_target_entity_token (maybe_target_entity_token), + KEY index_event_type (event_type) + +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;