diff --git a/migrations/2021-05-15-071601_assets/down.sql b/migrations/2021-05-15-071601_assets/down.sql index e1d28ed709..872ae266d7 100644 --- a/migrations/2021-05-15-071601_assets/down.sql +++ b/migrations/2021-05-15-071601_assets/down.sql @@ -2,5 +2,4 @@ # noinspection SqlResolveForFile drop table tts_models; -drop table w2l_templates; -drop table voices; \ No newline at end of file +drop table w2l_templates; \ No newline at end of file diff --git a/migrations/2021-05-15-071601_assets/up.sql b/migrations/2021-05-15-071601_assets/up.sql index 181c2b5430..9f7348fedf 100644 --- a/migrations/2021-05-15-071601_assets/up.sql +++ b/migrations/2021-05-15-071601_assets/up.sql @@ -25,10 +25,6 @@ CREATE TABLE tts_models ( -- If there's a newer version, we can disable this one. maybe_updated_model_token VARCHAR(32) DEFAULT NULL, - -- (Maybe) users can upload their own private models. - -- They can choose to make them public later. - is_private_for_creator BOOLEAN NOT NULL DEFAULT FALSE, - -- (THIS MIGHT NOT BE USED) -- NB: DO NOT SORT! -- THIS MUST MATCH THE RESPECTIVE JOBS TABLE. @@ -38,14 +34,6 @@ CREATE TABLE tts_models ( 'private' ) NOT NULL DEFAULT 'public', - -- In this case, a moderator disables it. - is_mod_disabled BOOLEAN NOT NULL DEFAULT FALSE, - - -- If a moderator has comments. - maybe_mod_comments VARCHAR(255) DEFAULT NULL, - -- The last moderator that made changes. - maybe_mod_user_token VARCHAR(32) DEFAULT NULL, - -- NB: DO NOT CHANGE ORDER; APPEND ONLY! -- THIS MUST MATCH THE RESPECTIVE JOBS TABLE. tts_model_type ENUM( @@ -56,20 +44,23 @@ CREATE TABLE tts_models ( ) NOT NULL DEFAULT 'not-set', -- Can be linked to a well-known voice - maybe_voice_token VARCHAR(32) DEFAULT NULL, + maybe_subject_token VARCHAR(32) DEFAULT NULL, + maybe_actor_subject_token VARCHAR(32) DEFAULT NULL, -- The name of the voice. -- If voice_token is set, then it's authoritative instead. voice_name VARCHAR(255) NOT NULL, - -- If the voice is "happy" or a singer "a-capella", etc. - -- If voice_token is set, it's authoritative. - voice_characteristic VARCHAR(255) DEFAULT NULL, - -- The speaker (in the case of cartoon characters) -- If voice_token is set, it's authoritative. voice_actor_name VARCHAR(255) DEFAULT NULL, + -- If the voice is "happy" or a singer "a-capella", etc. + voice_characteristic VARCHAR(255) DEFAULT NULL, + + -- Eg. ("poor quality", "trained longer", etc.) + extra_model_disambiguation VARCHAR(255) DEFAULT NULL, + -- The description of the model in markdown. description_markdown TEXT NOT NULL, @@ -77,7 +68,7 @@ CREATE TABLE tts_models ( description_rendered_html TEXT NOT NULL, -- The filename that was used at upload time. - original_filename CHAR(255) NOT NULL, + original_filename VARCHAR(255) NOT NULL, -- The pytorch model -- For now, this will be a hash of the file contents. @@ -87,10 +78,19 @@ CREATE TABLE tts_models ( -- Calculated average, on a scale of 0-100 -- Null with zero ratings. calculated_average_score INT(3) DEFAULT NULL, + -- Other metrics calculated_total_ratings_submitted_count INT(10) NOT NULL DEFAULT 0, calculated_total_uses_count BIGINT(10) NOT NULL DEFAULT 0, + -- In this case, a moderator disables it. + is_mod_disabled BOOLEAN NOT NULL DEFAULT FALSE, + + -- If a moderator has comments. + maybe_mod_comments VARCHAR(255) DEFAULT NULL, + -- The last moderator that made changes. + maybe_mod_user_token VARCHAR(32) DEFAULT NULL, + created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, @@ -105,10 +105,12 @@ CREATE TABLE tts_models ( KEY fk_maybe_updated_model_token (maybe_updated_model_token), KEY fk_creator_user_token (creator_user_token), KEY fk_maybe_mod_user_token (maybe_mod_user_token), - KEY fk_maybe_voice_token (maybe_voice_token), + KEY fk_maybe_subject_token (maybe_subject_token), + KEY fk_maybe_actor_subject_token (maybe_actor_subject_token), KEY index_creator_ip_address (creator_ip_address), + KEY index_creator_set_visibility (creator_set_visibility), KEY index_private_bucket_hash (private_bucket_hash), - KEY index_maybe_mod_user_token (maybe_mod_user_token) + KEY index_is_mod_disabled (is_mod_disabled) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; @@ -131,12 +133,21 @@ CREATE TABLE w2l_templates ( 'video' ) NOT NULL DEFAULT 'not-set', - -- The title of the template. + -- Can be linked to a well-known voice + maybe_subject_token VARCHAR(32) DEFAULT NULL, + maybe_actor_subject_token VARCHAR(32) DEFAULT NULL, + + -- The title of the template. title CHAR(255) NOT NULL, - -- Users can upload their own private templates. - -- They can choose to make them public later. - is_private_for_creator BOOLEAN NOT NULL DEFAULT FALSE, + -- (THIS MIGHT NOT BE USED) + -- NB: DO NOT SORT! + -- THIS MUST MATCH THE RESPECTIVE JOBS TABLE. + creator_set_visibility ENUM( + 'public', + 'hidden', + 'private' + ) NOT NULL DEFAULT 'public', -- The description of the template in markdown. description_markdown TEXT NOT NULL, @@ -160,6 +171,15 @@ CREATE TABLE w2l_templates ( -- For the thumbnail we show. public_bucket_hash CHAR(32) NOT NULL, + -- In this case, a moderator disables it. + is_mod_disabled BOOLEAN NOT NULL DEFAULT FALSE, + + -- If a moderator has comments. + maybe_mod_comments VARCHAR(255) DEFAULT NULL, + + -- The last moderator that made changes. + maybe_mod_user_token VARCHAR(32) DEFAULT NULL, + created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, @@ -170,54 +190,16 @@ CREATE TABLE w2l_templates ( PRIMARY KEY (id), UNIQUE KEY (token), UNIQUE KEY (updatable_slug), + KEY fk_creator_user_token (creator_user_token), + KEY fk_maybe_mod_user_token (maybe_mod_user_token), + KEY fk_maybe_subject_token (maybe_subject_token), + KEY fk_maybe_actor_subject_token (maybe_actor_subject_token), + KEY index_template_type (template_type), + KEY index_creator_ip_address (creator_ip_address), KEY index_private_bucket_hash (private_bucket_hash), - KEY index_public_bucket_hash (public_bucket_hash) + KEY index_public_bucket_hash (public_bucket_hash), + KEY index_creator_set_visibility (creator_set_visibility), + KEY index_is_mod_disabled (is_mod_disabled) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; -CREATE TABLE voices ( - -- Not used for anything except replication. - id BIGINT(20) NOT NULL AUTO_INCREMENT, - - -- Effective "primary key" (PUBLIC) - token VARCHAR(32) NOT NULL, - - -- The URL we access the voice at. - -- These should be stable, but could be changed if necessary. - -- As such, these should not be foreign keys. - updatable_slug VARCHAR(64) NOT NULL, - - -- We can assign an exemplary model to the voice - default_model_token VARCHAR(32) DEFAULT NULL, - - -- If a moderator author disables it. - -- This should prevent the voice from showing up in lists. - mod_disabled BOOLEAN NOT NULL DEFAULT FALSE, - - -- The name of the voice - voice_name VARCHAR(255) NOT NULL, - - -- If the voice is "happy" or a singer "a-capella", etc. - voice_characteristic VARCHAR(255) DEFAULT NULL, - - -- The speaker (in the case of cartoon characters) - voice_actor_name VARCHAR(255) DEFAULT NULL, - - -- The 800x600 image - image_banner_public_bucket_hash CHAR(32) DEFAULT NULL, - - -- The square avatar image - image_square_public_bucket_hash CHAR(32) DEFAULT NULL, - - created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, - updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - - -- If this is removed by a mod. - deleted_at TIMESTAMP NULL, - - -- INDICES -- - PRIMARY KEY (id), - UNIQUE KEY (token), - UNIQUE KEY (updatable_slug) - -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; diff --git a/migrations/2021-05-15-071602_voices/down.sql b/migrations/2021-05-15-071602_voices/down.sql new file mode 100644 index 0000000000..199e0c7583 --- /dev/null +++ b/migrations/2021-05-15-071602_voices/down.sql @@ -0,0 +1,5 @@ +# noinspection SqlNoDataSourceInspectionForFile +# noinspection SqlResolveForFile + +drop table subjects; +drop table voices; diff --git a/migrations/2021-05-15-071602_voices/up.sql b/migrations/2021-05-15-071602_voices/up.sql new file mode 100644 index 0000000000..1d5eed5fc4 --- /dev/null +++ b/migrations/2021-05-15-071602_voices/up.sql @@ -0,0 +1,140 @@ +# noinspection SqlNoDataSourceInspectionForFile +# noinspection SqlResolveForFile + +-- These can be people, cartoon characters, fictional characters, etc. +-- Subjects may be "played" by different entities. +CREATE TABLE subjects ( + -- Not used for anything except replication. + id BIGINT(20) NOT NULL AUTO_INCREMENT, + + -- Effective "primary key" (PUBLIC) + token VARCHAR(32) NOT NULL, + + -- The name of the subject + -- Might have parens to disambiguate, eg. "JFK (Clone High)" + subject_name VARCHAR(255) NOT NULL, + + -- The URL we access the voice at. + -- These should be stable, but could be changed if necessary. + -- As such, these should not be foreign keys. + updatable_slug VARCHAR(64) NOT NULL, + + -- The type of subject + -- For eg. "JFK (Clone High)", that would be a separate subject. + type ENUM( + 'not-set', + 'real-person', + 'fictional-character' + ) NOT NULL DEFAULT 'not-set', + + -- The description of the model in markdown. + description_markdown TEXT NOT NULL, + + -- Generated HTML (not user-editable). + description_rendered_html TEXT NOT NULL, + + -- The person that created the template. + creator_user_token VARCHAR(32) NOT NULL, + + -- For abuse tracking. + -- Wide enough for IPv4/6 + creator_ip_address VARCHAR(40) NOT NULL, + + -- The person that created the template. + -- More than just mods may update. + maybe_updater_user_token VARCHAR(32) NOT NULL, + + -- More than just mods may update. + -- For abuse tracking. + -- Wide enough for IPv4/6 + maybe_updater_ip_address VARCHAR(40) NOT NULL, + + -- We can assign an exemplary model to the subject + maybe_default_tts_model_token VARCHAR(32) DEFAULT NULL, + maybe_default_w2l_template_token VARCHAR(32) DEFAULT NULL, + + -- The 800x600 image + maybe_image_banner_public_bucket_hash CHAR(32) DEFAULT NULL, + + -- The square avatar image + maybe_image_square_public_bucket_hash CHAR(32) DEFAULT NULL, + + -- If a moderator author disables it. + -- This should prevent the voice from showing up in lists. + -- Eg. if someone creates "Hitler", we'd want to prevent it from showing up. + is_mod_disabled BOOLEAN NOT NULL DEFAULT FALSE, + + -- If a moderator has comments. + maybe_mod_comments VARCHAR(255) DEFAULT NULL, + -- The last moderator that made changes. + maybe_mod_user_token VARCHAR(32) DEFAULT NULL, + + created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + + -- If this is removed by a mod. + -- It completely disappears from the system. + deleted_at TIMESTAMP NULL, + + -- INDICES -- + PRIMARY KEY (id), + UNIQUE KEY (token), + UNIQUE KEY (updatable_slug), + KEY fk_creator_user_token (creator_user_token), + KEY fk_maybe_updater_user_token (maybe_updater_user_token), + KEY fk_maybe_default_tts_model_token (maybe_default_tts_model_token), + KEY fk_maybe_default_w2l_template_token (maybe_default_w2l_template_token), + KEY fk_maybe_mod_user_token (maybe_mod_user_token), + KEY index_type (type), + KEY index_creator_ip_address (creator_ip_address), + KEY index_maybe_updater_ip_address (maybe_updater_ip_address), + KEY index_is_mod_disabled (is_mod_disabled) + +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; + +CREATE TABLE voices ( + -- Not used for anything except replication. + id BIGINT(20) NOT NULL AUTO_INCREMENT, + + -- Effective "primary key" (PUBLIC) + token VARCHAR(32) NOT NULL, + + -- The URL we access the voice at. + -- These should be stable, but could be changed if necessary. + -- As such, these should not be foreign keys. + updatable_slug VARCHAR(64) NOT NULL, + + -- We can assign an exemplary model to the voice + default_model_token VARCHAR(32) DEFAULT NULL, + + -- If a moderator author disables it. + -- This should prevent the voice from showing up in lists. + mod_disabled BOOLEAN NOT NULL DEFAULT FALSE, + + -- The name of the voice + voice_name VARCHAR(255) NOT NULL, + + -- If the voice is "happy" or a singer "a-capella", etc. + voice_characteristic VARCHAR(255) DEFAULT NULL, + + -- The speaker (in the case of cartoon characters) + voice_actor_name VARCHAR(255) DEFAULT NULL, + + -- The 800x600 image + image_banner_public_bucket_hash CHAR(32) DEFAULT NULL, + + -- The square avatar image + image_square_public_bucket_hash CHAR(32) DEFAULT NULL, + + created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + + -- If this is removed by a mod. + deleted_at TIMESTAMP NULL, + + -- INDICES -- + PRIMARY KEY (id), + UNIQUE KEY (token), + UNIQUE KEY (updatable_slug) + +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;