From 44f5e14ded2247bdc80a0407c0bf719c5568b8a3 Mon Sep 17 00:00:00 2001 From: Brandon Thomas Date: Fri, 3 May 2024 23:15:15 -0400 Subject: [PATCH] SQL for featured_items table --- .../2024-05-04-025530_featured_items/down.sql | 5 +++ .../2024-05-04-025530_featured_items/up.sql | 40 +++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 _sql/migrations/2024-05-04-025530_featured_items/down.sql create mode 100644 _sql/migrations/2024-05-04-025530_featured_items/up.sql diff --git a/_sql/migrations/2024-05-04-025530_featured_items/down.sql b/_sql/migrations/2024-05-04-025530_featured_items/down.sql new file mode 100644 index 0000000000..3b9c227356 --- /dev/null +++ b/_sql/migrations/2024-05-04-025530_featured_items/down.sql @@ -0,0 +1,5 @@ +-- noinspection SqlDialectInspectionForFile +-- noinspection SqlNoDataSourceInspectionForFile +-- noinspection SqlResolveForFile + +DROP TABLE featured_items; diff --git a/_sql/migrations/2024-05-04-025530_featured_items/up.sql b/_sql/migrations/2024-05-04-025530_featured_items/up.sql new file mode 100644 index 0000000000..ae9436d156 --- /dev/null +++ b/_sql/migrations/2024-05-04-025530_featured_items/up.sql @@ -0,0 +1,40 @@ +-- noinspection SqlDialectInspectionForFile +-- noinspection SqlNoDataSourceInspectionForFile +-- noinspection SqlResolveForFile + +CREATE TABLE featured_items ( + -- Not used for anything except replication. + id BIGINT(20) NOT NULL AUTO_INCREMENT, + + -- ========== ENTITY LINKAGE ========== + + -- The type of record this is attached to + -- Currently supported values: + -- * 'model_weight' + -- * 'media_file' + entity_type VARCHAR(32) NOT NULL, + + -- The token for the record. + entity_token VARCHAR(32) NOT NULL, + + -- ========== SORTING ========== + + -- A sorted ordering (optional) for pagination + maybe_sort_order INT UNSIGNED DEFAULT NULL, + + -- ========== TIMESTAMPS ========== + + created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + deleted_at TIMESTAMP NULL, + + -- INDICES -- + PRIMARY KEY (id), + UNIQUE KEY (entity_type, entity_token), + + KEY index_maybe_sort_order_asc (maybe_sort_order ASC), + KEY index_maybe_sort_order_desc (maybe_sort_order DESC), + + KEY index_created_at (created_at), + KEY index_deleted_at (deleted_at) + +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;