diff --git a/crates/app/storyteller_web/src/http_server/endpoints/categories/create_category.rs b/crates/app/storyteller_web/src/http_server/endpoints/categories/create_category.rs new file mode 100644 index 0000000000..e69de29bb2 diff --git a/crates/app/storyteller_web/src/http_server/endpoints/categories/delete_category.rs b/crates/app/storyteller_web/src/http_server/endpoints/categories/delete_category.rs new file mode 100644 index 0000000000..e69de29bb2 diff --git a/crates/app/storyteller_web/src/http_server/endpoints/categories/edit_category.rs b/crates/app/storyteller_web/src/http_server/endpoints/categories/edit_category.rs new file mode 100644 index 0000000000..e69de29bb2 diff --git a/crates/app/storyteller_web/src/http_server/endpoints/categories/list_categories.rs b/crates/app/storyteller_web/src/http_server/endpoints/categories/list_categories.rs new file mode 100644 index 0000000000..e69de29bb2 diff --git a/crates/app/storyteller_web/src/http_server/endpoints/categories/mod.rs b/crates/app/storyteller_web/src/http_server/endpoints/categories/mod.rs new file mode 100644 index 0000000000..ed0a0cfaed --- /dev/null +++ b/crates/app/storyteller_web/src/http_server/endpoints/categories/mod.rs @@ -0,0 +1,4 @@ +pub mod create_category; +pub mod delete_category; +pub mod edit_category; +pub mod list_categories; \ No newline at end of file diff --git a/crates/app/storyteller_web/src/http_server/endpoints/mod.rs b/crates/app/storyteller_web/src/http_server/endpoints/mod.rs index 1bb6fcabce..f7f14dfbc9 100644 --- a/crates/app/storyteller_web/src/http_server/endpoints/mod.rs +++ b/crates/app/storyteller_web/src/http_server/endpoints/mod.rs @@ -1,3 +1,4 @@ +pub mod categories; pub mod events; pub mod leaderboard; pub mod misc; diff --git a/migrations/2021-12-20-230000_model_categories/down.sql b/migrations/2021-12-20-230000_model_categories/down.sql index ba45bcd3c8..986333f646 100644 --- a/migrations/2021-12-20-230000_model_categories/down.sql +++ b/migrations/2021-12-20-230000_model_categories/down.sql @@ -3,4 +3,5 @@ -- noinspection SqlResolveForFile DROP TABLE model_categories; -DROP TABLE model_category_assignments; \ No newline at end of file +DROP TABLE tts_category_assignments; +DROP TABLE w2l_category_assignments; diff --git a/migrations/2021-12-20-230000_model_categories/up.sql b/migrations/2021-12-20-230000_model_categories/up.sql index 84562b47f4..3dbb313d4d 100644 --- a/migrations/2021-12-20-230000_model_categories/up.sql +++ b/migrations/2021-12-20-230000_model_categories/up.sql @@ -9,6 +9,14 @@ CREATE TABLE model_categories ( -- Visible "primary key" token VARCHAR(32) NOT NULL, + -- ========== MODEL TYPE ========== + + model_type ENUM( + 'not_set', + 'tts', + 'w2l' + ) NOT NULL DEFAULT 'not_set', + -- ========== CATEGORY TOPOLOGY ========== -- Optional foreign key link to super category. @@ -16,7 +24,7 @@ CREATE TABLE model_categories ( super_category_token VARCHAR(32) DEFAULT NULL, -- If this category can be applied directly to models. - can_have_models BOOLEAN NOT NULL DEFAULT false, + can_directly_have_models BOOLEAN NOT NULL DEFAULT false, -- If this category can have subcategories. can_have_subcategories BOOLEAN NOT NULL DEFAULT false, @@ -70,14 +78,54 @@ CREATE TABLE model_categories ( PRIMARY KEY (id), UNIQUE KEY (token), KEY fk_super_category_token (super_category_token), - KEY index_can_have_models (can_have_models), + KEY index_model_type (model_type), + KEY index_can_directly_have_models (can_directly_have_models), KEY index_can_have_subcategories (can_have_subcategories), KEY index_is_mod_approved (is_mod_approved) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; -- Join table assigning models to zero or more categories. -CREATE TABLE model_category_assignments ( +CREATE TABLE tts_category_assignments ( + -- Not used for anything except replication. + id BIGINT(20) NOT NULL AUTO_INCREMENT, + + model_token VARCHAR(32) NOT NULL, + category_token VARCHAR(32) NOT NULL, + + -- ========== USER DETAILS ========== + + -- The person that created the assignment. + -- This can be the model owner or a moderator. + category_addition_user_token VARCHAR(32) NOT NULL, + + -- The person that removed the assignment. + -- This can be the model owner or a moderator. + category_removal_user_token VARCHAR(32) NOT NULL, + + -- For abuse tracking. + -- THIS CAN BE A MODERATOR FOR SIMPLICITY. + -- Wide enough for IPv4/6 + ip_address_creation VARCHAR(40) NOT NULL, + ip_address_last_update VARCHAR(40) NOT NULL, + + -- ========== TIMESTAMPS ========== + + created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + deleted_at TIMESTAMP NULL, + + -- INDICES -- + PRIMARY KEY (id), + UNIQUE KEY (model_token, category_token), + KEY fk_model_token (model_token), + KEY fk_category_token (category_token), + KEY index_deleted_at (deleted_at) + +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; + +-- Join table assigning models to zero or more categories. +CREATE TABLE w2l_category_assignments ( -- Not used for anything except replication. id BIGINT(20) NOT NULL AUTO_INCREMENT,