diff --git a/_sql/migrations/2025-07-23-200905_prompt_context_items/down.sql b/_sql/migrations/2025-07-23-200905_prompt_context_items/down.sql new file mode 100644 index 0000000000..d8a73766c5 --- /dev/null +++ b/_sql/migrations/2025-07-23-200905_prompt_context_items/down.sql @@ -0,0 +1,5 @@ +-- noinspection SqlDialectInspectionForFile +-- noinspection SqlNoDataSourceInspectionForFile +-- noinspection SqlResolveForFile + +DROP TABLE prompt_context_items; diff --git a/_sql/migrations/2025-07-23-200905_prompt_context_items/up.sql b/_sql/migrations/2025-07-23-200905_prompt_context_items/up.sql new file mode 100644 index 0000000000..09aa8a6df6 --- /dev/null +++ b/_sql/migrations/2025-07-23-200905_prompt_context_items/up.sql @@ -0,0 +1,30 @@ +-- noinspection SqlDialectInspectionForFile +-- noinspection SqlNoDataSourceInspectionForFile +-- noinspection SqlResolveForFile + +-- An n:m join table between prompts and media_files. +-- This associates mostly image media files with prompts, though we could conceivably +-- also store 3D sets, etc. +CREATE TABLE prompt_context_items ( + -- Not used for anything except replication. + id BIGINT(20) NOT NULL AUTO_INCREMENT, + + -- The semantic type of context. + context_semantic_type VARCHAR(16) NOT NULL, + + -- Foreign key, many-to-many + -- There is no uniqueness constraint for (prompt_token, media_token) because a user + -- might attach many duplicate images to the same prompt. + prompt_token VARCHAR(32) NOT NULL, + + -- Foreign key to the media token + -- There is no uniqueness constraint for (prompt_token, media_token) because a user + -- might attach many duplicate images to the same prompt. + media_token VARCHAR(32) NOT NULL, + + -- INDICES -- + PRIMARY KEY (id), + KEY index_prompt_token (prompt_token), + KEY index_media_token (media_token) + +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;