diff --git a/_database/sql/migrations/2026-07-10-063412-0000_drop_tag_uses/down.sql b/_database/sql/migrations/2026-07-10-063412-0000_drop_tag_uses/down.sql new file mode 100644 index 0000000000..b78c7d93d3 --- /dev/null +++ b/_database/sql/migrations/2026-07-10-063412-0000_drop_tag_uses/down.sql @@ -0,0 +1,35 @@ +-- noinspection SqlDialectInspectionForFile +-- noinspection SqlNoDataSourceInspectionForFile +-- noinspection SqlResolveForFile + +CREATE TABLE tag_uses ( + -- Not used for anything except replication. + id BIGINT(20) NOT NULL AUTO_INCREMENT, + + -- ========== TAG LINK ========== + + -- Token of the tag + tag_token VARCHAR(32) NOT NULL, + + -- ========== LINKED ENTITY ========== + + -- Entity the tag is linked to (composite key) + entity_type VARCHAR(32) NOT NULL, + + -- Entity the tag is linked to (composite key) + entity_token VARCHAR(32) NOT NULL, + + -- ========== TIMESTAMPS ========== + + created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + maybe_deleted_at TIMESTAMP NULL, + + -- INDICES -- + PRIMARY KEY (id), + UNIQUE KEY (tag_token, entity_type, entity_token), + + KEY index_tag_token (tag_token), + KEY index_entity_type_and_token (entity_type, entity_token), + KEY index_maybe_deleted_at (maybe_deleted_at) + +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; diff --git a/_database/sql/migrations/2026-07-10-063412-0000_drop_tag_uses/up.sql b/_database/sql/migrations/2026-07-10-063412-0000_drop_tag_uses/up.sql new file mode 100644 index 0000000000..7c18c6c40d --- /dev/null +++ b/_database/sql/migrations/2026-07-10-063412-0000_drop_tag_uses/up.sql @@ -0,0 +1,5 @@ +-- noinspection SqlDialectInspectionForFile +-- noinspection SqlNoDataSourceInspectionForFile +-- noinspection SqlResolveForFile + +DROP TABLE tag_uses; diff --git a/_database/sql/migrations/2026-07-10-063413-0000_drop_tags/down.sql b/_database/sql/migrations/2026-07-10-063413-0000_drop_tags/down.sql new file mode 100644 index 0000000000..63127c9182 --- /dev/null +++ b/_database/sql/migrations/2026-07-10-063413-0000_drop_tags/down.sql @@ -0,0 +1,30 @@ +-- noinspection SqlDialectInspectionForFile +-- noinspection SqlNoDataSourceInspectionForFile +-- noinspection SqlResolveForFile + +CREATE TABLE tags ( + -- Not used for anything except replication. + id BIGINT(20) NOT NULL AUTO_INCREMENT, + + -- ========== PRIMARY FUNCTIONALITY ========== + + -- Effective "primary key" of the beta key. + token VARCHAR(32) NOT NULL, + + -- The actual value of the tag. + -- The code will normalize this. + tag_value VARCHAR(255) NOT NULL, + + -- ========== TIMESTAMPS ========== + + created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + maybe_deleted_at TIMESTAMP NULL, + + -- INDICES -- + PRIMARY KEY (id), + UNIQUE KEY (token), + UNIQUE KEY (tag_value), + + KEY index_maybe_deleted_at (maybe_deleted_at) + +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; diff --git a/_database/sql/migrations/2026-07-10-063413-0000_drop_tags/up.sql b/_database/sql/migrations/2026-07-10-063413-0000_drop_tags/up.sql new file mode 100644 index 0000000000..6c3399567c --- /dev/null +++ b/_database/sql/migrations/2026-07-10-063413-0000_drop_tags/up.sql @@ -0,0 +1,5 @@ +-- noinspection SqlDialectInspectionForFile +-- noinspection SqlNoDataSourceInspectionForFile +-- noinspection SqlResolveForFile + +DROP TABLE tags;