From 5108f94c0f33ca53dd6f4d3b34f7094345505069 Mon Sep 17 00:00:00 2001 From: Brandon Thomas Date: Thu, 14 Dec 2023 21:45:44 -0500 Subject: [PATCH] Lots of schema changes afoot - model_weights migration, covers, samples Model weights migration (old tokens): - model_weights.maybe_migration_old_model_token Model weights migration (new tokens): - tts_models.maybe_migration_new_model_weights_token - vocoder_models.maybe_migration_new_model_weights_token - voice_conversion_models.maybe_migration_new_model_weights_token Cover and banner images for models: - model_weights.maybe_banner_media_file_token - model_weights.maybe_cover_media_file_token Avatar and banner images for users: - users.maybe_avatar_media_file_token - users.maybe_cover_media_file_token Sample multimedia for models: - model_weights_samples (new table) --- .../down.sql | 5 + .../up.sql | 10 + .../down.sql | 6 + .../up.sql | 10 + .../down.sql | 5 + .../up.sql | 10 + .../down.sql | 5 + .../up.sql | 10 + .../down.sql | 5 + .../up.sql | 10 + .../down.sql | 6 + .../up.sql | 10 + .../down.sql | 5 + .../up.sql | 10 + .../down.sql | 5 + .../up.sql | 10 + .../down.sql | 5 + .../up.sql | 47 ++++ _sql/migrations_squashed/model_weights.sql | 202 ++++++++++++++++++ .../tts_tables/tts_models.sql | 5 + .../tts_tables/vocoder_models.sql | 5 + .../migrations_squashed/user_tables/users.sql | 8 + .../voice_conversion_models.sql | 5 + 23 files changed, 399 insertions(+) create mode 100644 _sql/migrations/2023-12-15-015254_alter_model_weights_add_old_token/down.sql create mode 100644 _sql/migrations/2023-12-15-015254_alter_model_weights_add_old_token/up.sql create mode 100644 _sql/migrations/2023-12-15-015311_alter_voice_conversion_models_add_new_token/down.sql create mode 100644 _sql/migrations/2023-12-15-015311_alter_voice_conversion_models_add_new_token/up.sql create mode 100644 _sql/migrations/2023-12-15-015319_alter_tts_models_add_new_token/down.sql create mode 100644 _sql/migrations/2023-12-15-015319_alter_tts_models_add_new_token/up.sql create mode 100644 _sql/migrations/2023-12-15-015329_alter_vocoder_models_add_new_token/down.sql create mode 100644 _sql/migrations/2023-12-15-015329_alter_vocoder_models_add_new_token/up.sql create mode 100644 _sql/migrations/2023-12-15-024344_alter_model_weights_add_avatar_media_file_token/down.sql create mode 100644 _sql/migrations/2023-12-15-024344_alter_model_weights_add_avatar_media_file_token/up.sql create mode 100644 _sql/migrations/2023-12-15-024350_alter_model_weights_add_cover_media_file_token/down.sql create mode 100644 _sql/migrations/2023-12-15-024350_alter_model_weights_add_cover_media_file_token/up.sql create mode 100644 _sql/migrations/2023-12-15-034614_alter_users_add_avatar_media_file_token/down.sql create mode 100644 _sql/migrations/2023-12-15-034614_alter_users_add_avatar_media_file_token/up.sql create mode 100644 _sql/migrations/2023-12-15-034644_alter_users_add_cover_media_file_token/down.sql create mode 100644 _sql/migrations/2023-12-15-034644_alter_users_add_cover_media_file_token/up.sql create mode 100644 _sql/migrations/2023-12-15-044416_model_weights_samples/down.sql create mode 100644 _sql/migrations/2023-12-15-044416_model_weights_samples/up.sql create mode 100644 _sql/migrations_squashed/model_weights.sql diff --git a/_sql/migrations/2023-12-15-015254_alter_model_weights_add_old_token/down.sql b/_sql/migrations/2023-12-15-015254_alter_model_weights_add_old_token/down.sql new file mode 100644 index 0000000000..6a822bee27 --- /dev/null +++ b/_sql/migrations/2023-12-15-015254_alter_model_weights_add_old_token/down.sql @@ -0,0 +1,5 @@ +-- noinspection SqlDialectInspectionForFile +-- noinspection SqlNoDataSourceInspectionForFile +-- noinspection SqlResolveForFile + +ALTER TABLE model_weights DROP COLUMN maybe_migration_old_model_token; diff --git a/_sql/migrations/2023-12-15-015254_alter_model_weights_add_old_token/up.sql b/_sql/migrations/2023-12-15-015254_alter_model_weights_add_old_token/up.sql new file mode 100644 index 0000000000..dbcdd42f8b --- /dev/null +++ b/_sql/migrations/2023-12-15-015254_alter_model_weights_add_old_token/up.sql @@ -0,0 +1,10 @@ +-- noinspection SqlDialectInspectionForFile +-- noinspection SqlNoDataSourceInspectionForFile +-- noinspection SqlResolveForFile + +ALTER TABLE model_weights + ADD COLUMN maybe_migration_old_model_token VARCHAR(32) DEFAULT NULL + AFTER cached_user_ratings_last_updated_at; + +ALTER TABLE model_weights + ADD UNIQUE INDEX unique_index_maybe_migration_old_model_token (maybe_migration_old_model_token); diff --git a/_sql/migrations/2023-12-15-015311_alter_voice_conversion_models_add_new_token/down.sql b/_sql/migrations/2023-12-15-015311_alter_voice_conversion_models_add_new_token/down.sql new file mode 100644 index 0000000000..9297e603a6 --- /dev/null +++ b/_sql/migrations/2023-12-15-015311_alter_voice_conversion_models_add_new_token/down.sql @@ -0,0 +1,6 @@ +-- noinspection SqlDialectInspectionForFile +-- noinspection SqlNoDataSourceInspectionForFile +-- noinspection SqlResolveForFile + +ALTER TABLE voice_conversion_models + DROP COLUMN maybe_migration_new_model_weights_token; diff --git a/_sql/migrations/2023-12-15-015311_alter_voice_conversion_models_add_new_token/up.sql b/_sql/migrations/2023-12-15-015311_alter_voice_conversion_models_add_new_token/up.sql new file mode 100644 index 0000000000..b14d521155 --- /dev/null +++ b/_sql/migrations/2023-12-15-015311_alter_voice_conversion_models_add_new_token/up.sql @@ -0,0 +1,10 @@ +-- noinspection SqlDialectInspectionForFile +-- noinspection SqlNoDataSourceInspectionForFile +-- noinspection SqlResolveForFile + +ALTER TABLE voice_conversion_models + ADD COLUMN maybe_migration_new_model_weights_token VARCHAR(32) DEFAULT NULL + AFTER maybe_mod_comments; + +ALTER TABLE voice_conversion_models + ADD UNIQUE INDEX unique_index_maybe_migration_new_model_weights_token (maybe_migration_new_model_weights_token); diff --git a/_sql/migrations/2023-12-15-015319_alter_tts_models_add_new_token/down.sql b/_sql/migrations/2023-12-15-015319_alter_tts_models_add_new_token/down.sql new file mode 100644 index 0000000000..8fae0f7f62 --- /dev/null +++ b/_sql/migrations/2023-12-15-015319_alter_tts_models_add_new_token/down.sql @@ -0,0 +1,5 @@ +-- noinspection SqlDialectInspectionForFile +-- noinspection SqlNoDataSourceInspectionForFile +-- noinspection SqlResolveForFile + +ALTER TABLE tts_models DROP COLUMN maybe_migration_new_model_weights_token; diff --git a/_sql/migrations/2023-12-15-015319_alter_tts_models_add_new_token/up.sql b/_sql/migrations/2023-12-15-015319_alter_tts_models_add_new_token/up.sql new file mode 100644 index 0000000000..569ab1f595 --- /dev/null +++ b/_sql/migrations/2023-12-15-015319_alter_tts_models_add_new_token/up.sql @@ -0,0 +1,10 @@ +-- noinspection SqlDialectInspectionForFile +-- noinspection SqlNoDataSourceInspectionForFile +-- noinspection SqlResolveForFile + +ALTER TABLE tts_models + ADD COLUMN maybe_migration_new_model_weights_token VARCHAR(32) DEFAULT NULL + AFTER maybe_mod_user_token; + +ALTER TABLE tts_models + ADD UNIQUE INDEX unique_index_maybe_migration_new_model_weights_token (maybe_migration_new_model_weights_token); diff --git a/_sql/migrations/2023-12-15-015329_alter_vocoder_models_add_new_token/down.sql b/_sql/migrations/2023-12-15-015329_alter_vocoder_models_add_new_token/down.sql new file mode 100644 index 0000000000..1238b82f67 --- /dev/null +++ b/_sql/migrations/2023-12-15-015329_alter_vocoder_models_add_new_token/down.sql @@ -0,0 +1,5 @@ +-- noinspection SqlDialectInspectionForFile +-- noinspection SqlNoDataSourceInspectionForFile +-- noinspection SqlResolveForFile + +ALTER TABLE vocoder_models DROP COLUMN maybe_migration_new_model_weights_token; diff --git a/_sql/migrations/2023-12-15-015329_alter_vocoder_models_add_new_token/up.sql b/_sql/migrations/2023-12-15-015329_alter_vocoder_models_add_new_token/up.sql new file mode 100644 index 0000000000..f804fad6f2 --- /dev/null +++ b/_sql/migrations/2023-12-15-015329_alter_vocoder_models_add_new_token/up.sql @@ -0,0 +1,10 @@ +-- noinspection SqlDialectInspectionForFile +-- noinspection SqlNoDataSourceInspectionForFile +-- noinspection SqlResolveForFile + +ALTER TABLE vocoder_models + ADD COLUMN maybe_migration_new_model_weights_token VARCHAR(32) DEFAULT NULL + AFTER maybe_mod_user_token; + +ALTER TABLE vocoder_models + ADD UNIQUE INDEX unique_index_maybe_migration_new_model_weights_token (maybe_migration_new_model_weights_token); diff --git a/_sql/migrations/2023-12-15-024344_alter_model_weights_add_avatar_media_file_token/down.sql b/_sql/migrations/2023-12-15-024344_alter_model_weights_add_avatar_media_file_token/down.sql new file mode 100644 index 0000000000..2ae3d04fca --- /dev/null +++ b/_sql/migrations/2023-12-15-024344_alter_model_weights_add_avatar_media_file_token/down.sql @@ -0,0 +1,5 @@ +-- noinspection SqlDialectInspectionForFile +-- noinspection SqlNoDataSourceInspectionForFile +-- noinspection SqlResolveForFile + +ALTER TABLE model_weights DROP COLUMN maybe_avatar_media_file_token; diff --git a/_sql/migrations/2023-12-15-024344_alter_model_weights_add_avatar_media_file_token/up.sql b/_sql/migrations/2023-12-15-024344_alter_model_weights_add_avatar_media_file_token/up.sql new file mode 100644 index 0000000000..2596c1afbf --- /dev/null +++ b/_sql/migrations/2023-12-15-024344_alter_model_weights_add_avatar_media_file_token/up.sql @@ -0,0 +1,10 @@ +-- noinspection SqlDialectInspectionForFile +-- noinspection SqlNoDataSourceInspectionForFile +-- noinspection SqlResolveForFile + +ALTER TABLE model_weights + ADD COLUMN maybe_avatar_media_file_token VARCHAR(32) DEFAULT NULL + AFTER maybe_thumbnail_token; + +ALTER TABLE model_weights + ADD INDEX index_maybe_avatar_media_file_token (maybe_avatar_media_file_token); diff --git a/_sql/migrations/2023-12-15-024350_alter_model_weights_add_cover_media_file_token/down.sql b/_sql/migrations/2023-12-15-024350_alter_model_weights_add_cover_media_file_token/down.sql new file mode 100644 index 0000000000..6458b44595 --- /dev/null +++ b/_sql/migrations/2023-12-15-024350_alter_model_weights_add_cover_media_file_token/down.sql @@ -0,0 +1,6 @@ +-- noinspection SqlDialectInspectionForFile +-- noinspection SqlNoDataSourceInspectionForFile +-- noinspection SqlResolveForFile + +ALTER TABLE model_weights DROP COLUMN maybe_cover_media_file_token; + diff --git a/_sql/migrations/2023-12-15-024350_alter_model_weights_add_cover_media_file_token/up.sql b/_sql/migrations/2023-12-15-024350_alter_model_weights_add_cover_media_file_token/up.sql new file mode 100644 index 0000000000..a04e0a1b18 --- /dev/null +++ b/_sql/migrations/2023-12-15-024350_alter_model_weights_add_cover_media_file_token/up.sql @@ -0,0 +1,10 @@ +-- noinspection SqlDialectInspectionForFile +-- noinspection SqlNoDataSourceInspectionForFile +-- noinspection SqlResolveForFile + +ALTER TABLE model_weights + ADD COLUMN maybe_cover_media_file_token VARCHAR(32) DEFAULT NULL + AFTER maybe_avatar_media_file_token; + +ALTER TABLE model_weights + ADD INDEX index_maybe_cover_media_file_token (maybe_cover_media_file_token); diff --git a/_sql/migrations/2023-12-15-034614_alter_users_add_avatar_media_file_token/down.sql b/_sql/migrations/2023-12-15-034614_alter_users_add_avatar_media_file_token/down.sql new file mode 100644 index 0000000000..2e84ec6bc5 --- /dev/null +++ b/_sql/migrations/2023-12-15-034614_alter_users_add_avatar_media_file_token/down.sql @@ -0,0 +1,5 @@ +-- noinspection SqlDialectInspectionForFile +-- noinspection SqlNoDataSourceInspectionForFile +-- noinspection SqlResolveForFile + +ALTER TABLE users DROP COLUMN maybe_avatar_media_file_token; diff --git a/_sql/migrations/2023-12-15-034614_alter_users_add_avatar_media_file_token/up.sql b/_sql/migrations/2023-12-15-034614_alter_users_add_avatar_media_file_token/up.sql new file mode 100644 index 0000000000..64c9a8a3d5 --- /dev/null +++ b/_sql/migrations/2023-12-15-034614_alter_users_add_avatar_media_file_token/up.sql @@ -0,0 +1,10 @@ +-- noinspection SqlDialectInspectionForFile +-- noinspection SqlNoDataSourceInspectionForFile +-- noinspection SqlResolveForFile + +ALTER TABLE users + ADD COLUMN maybe_avatar_media_file_token VARCHAR(32) DEFAULT NULL + AFTER ip_address_last_update; + +ALTER TABLE users + ADD INDEX index_maybe_avatar_media_file_token (maybe_avatar_media_file_token); diff --git a/_sql/migrations/2023-12-15-034644_alter_users_add_cover_media_file_token/down.sql b/_sql/migrations/2023-12-15-034644_alter_users_add_cover_media_file_token/down.sql new file mode 100644 index 0000000000..45237d79de --- /dev/null +++ b/_sql/migrations/2023-12-15-034644_alter_users_add_cover_media_file_token/down.sql @@ -0,0 +1,5 @@ +-- noinspection SqlDialectInspectionForFile +-- noinspection SqlNoDataSourceInspectionForFile +-- noinspection SqlResolveForFile + +ALTER TABLE users DROP COLUMN maybe_cover_media_file_token; diff --git a/_sql/migrations/2023-12-15-034644_alter_users_add_cover_media_file_token/up.sql b/_sql/migrations/2023-12-15-034644_alter_users_add_cover_media_file_token/up.sql new file mode 100644 index 0000000000..a467e50665 --- /dev/null +++ b/_sql/migrations/2023-12-15-034644_alter_users_add_cover_media_file_token/up.sql @@ -0,0 +1,10 @@ +-- noinspection SqlDialectInspectionForFile +-- noinspection SqlNoDataSourceInspectionForFile +-- noinspection SqlResolveForFile + +ALTER TABLE users + ADD COLUMN maybe_cover_media_file_token VARCHAR(32) DEFAULT NULL + AFTER maybe_avatar_media_file_token; + +ALTER TABLE users + ADD INDEX index_maybe_cover_media_file_token (maybe_cover_media_file_token); diff --git a/_sql/migrations/2023-12-15-044416_model_weights_samples/down.sql b/_sql/migrations/2023-12-15-044416_model_weights_samples/down.sql new file mode 100644 index 0000000000..9834047d63 --- /dev/null +++ b/_sql/migrations/2023-12-15-044416_model_weights_samples/down.sql @@ -0,0 +1,5 @@ +-- noinspection SqlDialectInspectionForFile +-- noinspection SqlNoDataSourceInspectionForFile +-- noinspection SqlResolveForFile + +DROP TABLE model_weights_samples; diff --git a/_sql/migrations/2023-12-15-044416_model_weights_samples/up.sql b/_sql/migrations/2023-12-15-044416_model_weights_samples/up.sql new file mode 100644 index 0000000000..f8d6752a85 --- /dev/null +++ b/_sql/migrations/2023-12-15-044416_model_weights_samples/up.sql @@ -0,0 +1,47 @@ +-- noinspection SqlDialectInspectionForFile +-- noinspection SqlNoDataSourceInspectionForFile +-- noinspection SqlResolveForFile + +CREATE TABLE model_weights_samples ( + -- Not used for anything except replication. + id BIGINT(20) NOT NULL AUTO_INCREMENT, + + -- ========== WEIGHTS CLASSIFICATION ========== + + -- Foreign key to model weights. + -- This is in a composite index with media_file_token to make sure a media file only applies + -- to a given model once. + model_weight_token VARCHAR(32) NOT NULL, + + -- Foreign key to media files + -- This is in a composite index with model_weight_token to make sure a media file only applies + -- to a given model once. + media_file_token VARCHAR(32) NOT NULL, + + -- Information about who set the sample + -- * automation + -- * author + -- * community + set_by VARCHAR(16) NOT NULL, + + -- Incremented with every update. + version INT NOT NULL DEFAULT 0, + + -- ========== TIMESTAMPS ========== + + 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. + user_deleted_at TIMESTAMP NULL, + mod_deleted_at TIMESTAMP NULL, + + -- INDICES -- + PRIMARY KEY (id), + UNIQUE KEY (model_weight_token, media_file_token), + + KEY index_model_weight_token (model_weight_token), + KEY index_media_file_token (media_file_token) + +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; diff --git a/_sql/migrations_squashed/model_weights.sql b/_sql/migrations_squashed/model_weights.sql new file mode 100644 index 0000000000..dee5401c72 --- /dev/null +++ b/_sql/migrations_squashed/model_weights.sql @@ -0,0 +1,202 @@ +-- NB: This is a manually squashed view of all the CREATE and ALTER statements, +-- with comments attached to the fields for centralized documentation. + +-- noinspection SqlDialectInspectionForFile +-- noinspection SqlNoDataSourceInspectionForFile +-- noinspection SqlResolveForFile + +-- Every type of fine tuned model that users can upload. +CREATE TABLE model_weights ( + -- Not used for anything except replication. + id BIGINT(20) NOT NULL AUTO_INCREMENT, + + -- Effective "primary key" (PUBLIC) + token VARCHAR(32) NOT NULL, + + -- ========== WEIGHTS CLASSIFICATION ========== + + -- The exact type of weights + -- Currently supported values: + -- * 'hifigan_tt2' - hifigan for Tacotron2; TTS vocoder + -- * 'rvc_v2' - RVC (v2); voice conversion + -- * 'sd_1.5' - Stable Diffusion 1.5; image generation + -- * 'sdxl' - Stable Diffusion XL; image generation + -- * 'so_vits_svc' - SVC; voice conversion + -- * 'tt2' - Tacotron2; TTS + weights_type VARCHAR(32) NOT NULL, + + -- The broader category of the weights + -- Currently supported values: + -- * 'image_generation' (SD1.5, SDXL) + -- * 'text_to_speech' (TT2) + -- * 'vocoder' (Hifigan) + -- * 'voice_conversion' (RVCv2, SVC) + weights_category VARCHAR(32) NOT NULL, + + + -- ========== MODEL DESCRIPTION ========== + + -- The "name" of the model, which might be complicated. + title VARCHAR(255) NOT NULL, + + -- TODO(bt, 2023-12-14): Delete the `maybe_thumbnail_token` column later. + -- We're using other columns instead. + maybe_thumbnail_token VARCHAR(32) DEFAULT NULL, + + -- The "avatar" image is a media file of type image that serves as a + -- small avatar or profile picture icon. + maybe_avatar_media_file_token VARCHAR(32) DEFAULT NULL, + + -- The "cover" image is a media file of type image that covers the + -- top of the page. + maybe_cover_media_file_token VARCHAR(32) DEFAULT NULL, + + -- The description of the model in markdown. + description_markdown TEXT NOT NULL, + + -- Generated HTML (not user-editable). + description_rendered_html TEXT NOT NULL, + + + -- ========== CREATOR DETAILS ========== + + -- The person that created the model. + creator_user_token VARCHAR(32) NOT NULL, + + -- For abuse tracking. + -- Wide enough for IPv4/6. + -- IP address of creator at time of creation. + creator_ip_address VARCHAR(40) NOT NULL, + + -- (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 synthetic id associated with this model. + -- These ids are incremented on a per-user basis to help users + -- sequence their own work. They serve no other purpose. + -- "weights" synthetic ids are incremented over all media files + -- creator_weights_synthetic_id BIGINT(20) DEFAULT NULL, + + -- "weights_type" synthetic ids are incremented over a given weight type + -- creator_weights_type_synthetic_id BIGINT(20) DEFAULT NULL, + + -- The last user to edit the model. This could be the creator or a moderator. + -- Check the future audit logs table for more info. + maybe_last_update_user_token VARCHAR(32) DEFAULT NULL, + + + -- ========== IMMUTABLE PROVENANCE AND METADATA ========== + + -- Where the file was originally downloaded (if it was downloaded) + original_download_url VARCHAR(512) DEFAULT NULL, + + -- The filename that was used at upload time (if available) + original_filename VARCHAR(255) DEFAULT NULL, + + -- File characteristics + file_size_bytes INT(10) NOT NULL DEFAULT 0, + + -- Checksum of the original weights file + -- SHA2 hash [SHA2 = CHAR(64), SHA1 = CHAR(40), MD5 = CHAR(32)] + -- Note that SHA2 is a hash family (SHA-228, SHA-256, SHA-384, SHA-512, SHA-512/224, SHA-512/256, ...) + -- and produces different lengths output depending on the choice of algorithm. + file_checksum_sha2 CHAR(64) NOT NULL, + + -- ========== BUCKET STORAGE ========== + + -- The hash for the bucket directory that contains the original upload + -- as well as any associated other files. + -- The bucket filename for the primary file (not including the directory path) is given by: + -- `[{maybe_private_bucket_prefix}]{private_bucket_hash}[{maybe_private_bucket_extension}]` + private_bucket_hash VARCHAR(32) NOT NULL, + + -- An optional prefix on the bucket filename. + -- If present, this will be prepended to the beginning of the bucket filename to access the file. + -- The bucket filename for the primary file (not including the directory path) is given by: + -- `[{maybe_private_bucket_prefix}]{private_directory_hash}[{maybe_private_bucket_extension}]` + maybe_private_bucket_prefix VARCHAR(16) DEFAULT NULL, + + -- An optional appended extension on the bucket filename. + -- If present, this will be appended to the end of the bucket filename to access the file. + -- To allow for flexibility, this extension typically will contain a leading period if + -- the file needs it (eg ".mp4" rather than "mp4")! + -- The bucket filename for the primary file (not including the directory path) is given by: + -- `[{maybe_private_bucket_prefix}]{private_directory_hash}[{maybe_private_bucket_extension}]` + maybe_private_bucket_extension VARCHAR(16) DEFAULT NULL, + + + -- ========== MODERATION DETAILS ========== + + -- Mods may have to approve of vc models for them to show up in a public index. + -- Models can be used by the author (or other parties that know the URL) before + -- they're approved, but unapproved models won't show up in public indices. + -- This is independent of other visibility controls (is_mod_disabled, deleted_at, + -- and creator_set_visibility) + -- is_public_listing_approved BOOLEAN DEFAULT NULL, + + -- Extremely popular models may be locked from deletion or modification by users. + -- is_locked_from_user_modification BOOLEAN NOT NULL DEFAULT FALSE, + + + -- ========== RATING AND RANKING ========== + + -- User ratings are cached on the model, but are *not* a source of truth. + -- Total count only includes "positive" and "negative" votes, not neutral ones. + cached_user_ratings_total_count INT(10) UNSIGNED NOT NULL DEFAULT 0, + + -- Total positive + cached_user_ratings_positive_count INT(10) UNSIGNED NOT NULL DEFAULT 0, + + -- Total negative + cached_user_ratings_negative_count INT(10) UNSIGNED NOT NULL DEFAULT 0, + + -- User ratings are cached on the model, but are *not* a source of truth. + -- Total count only includes "positive" and "negative" votes, not neutral ones. + maybe_cached_user_ratings_ratio FLOAT, + + -- When the cached ratings were last calculated and updated. + cached_user_ratings_last_updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + + + -- ========== MIGRATION DETAILS ========== + + -- If migrated from another table, this is the token of the original model. + maybe_migration_old_model_token VARCHAR(32) DEFAULT NULL, + + + -- ========== VECTOR CLOCK ========== + + -- Incremented with every update. + version INT NOT NULL DEFAULT 0, + + + -- ========== TIMESTAMPS ========== + + 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. + user_deleted_at TIMESTAMP NULL, + mod_deleted_at TIMESTAMP NULL, + + -- INDICES -- + PRIMARY KEY (id), + UNIQUE KEY (token) + + -- TODO: + -- KEY index_model_type (model_type), + -- KEY fk_maybe_vocoder_token (maybe_vocoder_token), + -- KEY fk_creator_user_token (creator_user_token), + -- KEY index_creator_set_visibility (creator_set_visibility), + -- KEY index_private_bucket_hash (private_bucket_hash), + -- KEY index_is_public_listing_approved (is_public_listing_approved), + -- KEY index_is_locked_from_user_modification (is_locked_from_user_modification) + +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; diff --git a/_sql/migrations_squashed/tts_tables/tts_models.sql b/_sql/migrations_squashed/tts_tables/tts_models.sql index 493d2c3cd2..ca6c71e565 100644 --- a/_sql/migrations_squashed/tts_tables/tts_models.sql +++ b/_sql/migrations_squashed/tts_tables/tts_models.sql @@ -200,6 +200,11 @@ CREATE TABLE tts_models ( -- The last moderator that made changes. maybe_mod_user_token VARCHAR(32) DEFAULT NULL, + -- ========== MIGRATION DETAILS ========== + + -- If migrated to model_weights, this is the new token + maybe_migration_new_model_weights_token VARCHAR(32) DEFAULT NULL, + -- ========== VECTOR CLOCK ========== -- Incremented with every update. diff --git a/_sql/migrations_squashed/tts_tables/vocoder_models.sql b/_sql/migrations_squashed/tts_tables/vocoder_models.sql index d11793c780..5c4a9c38ac 100644 --- a/_sql/migrations_squashed/tts_tables/vocoder_models.sql +++ b/_sql/migrations_squashed/tts_tables/vocoder_models.sql @@ -99,6 +99,11 @@ CREATE TABLE vocoder_models ( -- The last moderator that made changes. maybe_mod_user_token VARCHAR(32) DEFAULT NULL, + -- ========== MIGRATION DETAILS ========== + + -- If migrated to model_weights, this is the new token + maybe_migration_new_model_weights_token VARCHAR(32) DEFAULT NULL, + -- ========== VECTOR CLOCK ========== -- Incremented with every update. diff --git a/_sql/migrations_squashed/user_tables/users.sql b/_sql/migrations_squashed/user_tables/users.sql index 43b6805adb..1ea5fca0ef 100644 --- a/_sql/migrations_squashed/user_tables/users.sql +++ b/_sql/migrations_squashed/user_tables/users.sql @@ -53,6 +53,14 @@ CREATE TABLE users ( -- ========== DISPLAY / PROFILE ========== + -- The "avatar" image is a media file of type image that serves as a + -- small avatar or profile picture icon. + maybe_avatar_media_file_token VARCHAR(32) DEFAULT NULL, + + -- The "cover" image is a media file of type image that covers the + -- top of the page. + maybe_cover_media_file_token VARCHAR(32) DEFAULT NULL, + -- Gravatar image hashes are precomputed. email_gravatar_hash CHAR(32) NOT NULL, diff --git a/_sql/migrations_squashed/voice_conversion_models.sql b/_sql/migrations_squashed/voice_conversion_models.sql index cff4f387a9..d28f338ae9 100644 --- a/_sql/migrations_squashed/voice_conversion_models.sql +++ b/_sql/migrations_squashed/voice_conversion_models.sql @@ -121,6 +121,11 @@ CREATE TABLE voice_conversion_models ( -- If a moderator has comments. maybe_mod_comments VARCHAR(255) DEFAULT NULL, + -- ========== MIGRATION DETAILS ========== + + -- If migrated to model_weights, this is the new token + maybe_migration_new_model_weights_token VARCHAR(32) DEFAULT NULL, + -- ========== VECTOR CLOCK ========== -- Incremented with every update.