diff --git a/_migrations/2022-02-13-223514_twitch_event_action_configs/down.sql b/_migrations/2022-02-13-223514_twitch_event_action_configs/down.sql new file mode 100644 index 0000000000..5cdec879c1 --- /dev/null +++ b/_migrations/2022-02-13-223514_twitch_event_action_configs/down.sql @@ -0,0 +1,5 @@ +-- noinspection SqlDialectInspectionForFile +-- noinspection SqlNoDataSourceInspectionForFile +-- noinspection SqlResolveForFile + +DROP TABLE twitch_event_action_rules; diff --git a/_migrations/2022-02-13-223514_twitch_event_action_configs/up.sql b/_migrations/2022-02-13-223514_twitch_event_action_configs/up.sql new file mode 100644 index 0000000000..e90b326167 --- /dev/null +++ b/_migrations/2022-02-13-223514_twitch_event_action_configs/up.sql @@ -0,0 +1,44 @@ +-- noinspection SqlDialectInspectionForFile +-- noinspection SqlNoDataSourceInspectionForFile +-- noinspection SqlResolveForFile + +-- Multiple rows per user +CREATE TABLE twitch_event_action_rules( + -- Not used for anything except replication. + id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT, + + -- Effective "primary key" (PUBLIC) + token VARCHAR(32) NOT NULL, + + -- Foreign key to user + -- This is a FakeYou/Storyteller account, *NOT* a twitch user id. + user_token VARCHAR(32) NOT NULL, + + -- The user can rearrange the rules in the UI. + -- This will be the order they apply in if matched. + -- NB: There is nothing in MySQL to guarantee unique ordering. + user_specified_rule_order INT(10) UNSIGNED NOT NULL DEFAULT 0, + + -- What type of event we'll be responding to. + event_category ENUM( + 'bits', + 'channel_points', + 'chat_command' + ) NOT NULL, + + -- A JSON payload containing any predicates we wish to apply to the match. + -- eg. bits_value > 100 + -- eg. channel_points_award_name == "Mario Voice" + event_match_predicate MEDIUMTEXT NOT NULL, + + -- A JSON payload containing how we wish to respond to the event. + -- eg. tts M:model + event_response MEDIUMTEXT NOT NULL, + + -- INDICES -- + PRIMARY KEY (id), + UNIQUE KEY (token), + KEY fk_user_token (user_token), + KEY index_event_category (event_category) + +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; diff --git a/_migrations/2022-02-13-223523_twitch_general_settings/down.sql b/_migrations/2022-02-13-223523_twitch_general_settings/down.sql new file mode 100644 index 0000000000..bc9ea84a15 --- /dev/null +++ b/_migrations/2022-02-13-223523_twitch_general_settings/down.sql @@ -0,0 +1,5 @@ +-- noinspection SqlDialectInspectionForFile +-- noinspection SqlNoDataSourceInspectionForFile +-- noinspection SqlResolveForFile + +DROP TABLE twitch_general_settings; diff --git a/_migrations/2022-02-13-223523_twitch_general_settings/up.sql b/_migrations/2022-02-13-223523_twitch_general_settings/up.sql new file mode 100644 index 0000000000..76485f9448 --- /dev/null +++ b/_migrations/2022-02-13-223523_twitch_general_settings/up.sql @@ -0,0 +1,30 @@ +-- noinspection SqlDialectInspectionForFile +-- noinspection SqlNoDataSourceInspectionForFile +-- noinspection SqlResolveForFile + +-- One row per user. Contains all of the general (non-repeated) configs. +CREATE TABLE twitch_general_settings ( + -- Not used for anything except replication. + id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT, + + -- Foreign key to user + -- This is a FakeYou/Storyteller account, *NOT* a twitch user id. + user_token VARCHAR(32) NOT NULL, + + -- Kill switch for the entire service. + storyteller_is_enabled BOOLEAN NOT NULL DEFAULT FALSE, + + -- Kill switch for TTS. + tts_is_enabled BOOLEAN NOT NULL DEFAULT FALSE, + + -- Kill switch for W2L. + w2l_is_enabled BOOLEAN NOT NULL DEFAULT FALSE, + + -- Can set a fallback voice if a TTS voice goes missing. + maybe_fallback_tts_model_token VARCHAR(32) DEFAULT NULL, + + -- INDICES -- + PRIMARY KEY (id), + UNIQUE KEY (user_token) + +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;