Five new schema migrations

This commit is contained in:
Brandon Thomas committed 2024-02-14 05:27:01 -05:00
1 parent 00abb6230b
commit 53b2aedbb0
14 files changed
+84 -4

No files matched your search

@@ -0,0 +1,6 @@
-- noinspection SqlDialectInspectionForFile
-- noinspection SqlNoDataSourceInspectionForFile
-- noinspection SqlResolveForFile
ALTER TABLE model_weights
MODIFY COLUMN file_size_bytes INT(10) NOT NULL DEFAULT 0;
@@ -0,0 +1,6 @@
-- noinspection SqlDialectInspectionForFile
-- noinspection SqlNoDataSourceInspectionForFile
-- noinspection SqlResolveForFile
ALTER TABLE model_weights
MODIFY COLUMN file_size_bytes BIGINT(10) NOT NULL DEFAULT 0;
@@ -0,0 +1,5 @@
-- noinspection SqlDialectInspectionForFile
-- noinspection SqlNoDataSourceInspectionForFile
-- noinspection SqlResolveForFile
ALTER TABLE media_files DROP COLUMN maybe_text_transcript;
@@ -0,0 +1,7 @@
-- noinspection SqlDialectInspectionForFile
-- noinspection SqlNoDataSourceInspectionForFile
-- noinspection SqlResolveForFile
ALTER TABLE media_files
ADD COLUMN maybe_text_transcript TEXT DEFAULT NULL
AFTER maybe_frame_height;
@@ -0,0 +1,5 @@
-- noinspection SqlDialectInspectionForFile
-- noinspection SqlNoDataSourceInspectionForFile
-- noinspection SqlResolveForFile
ALTER TABLE media_files DROP COLUMN maybe_batch_token;
@@ -0,0 +1,10 @@
-- noinspection SqlDialectInspectionForFile
-- noinspection SqlNoDataSourceInspectionForFile
-- noinspection SqlResolveForFile
ALTER TABLE media_files
ADD COLUMN maybe_batch_token VARCHAR(32) DEFAULT NULL
AFTER is_batch_generated;
ALTER TABLE media_files
ADD INDEX index_maybe_batch_token (maybe_batch_token);
@@ -0,0 +1,5 @@
-- noinspection SqlDialectInspectionForFile
-- noinspection SqlNoDataSourceInspectionForFile
-- noinspection SqlResolveForFile
ALTER TABLE generic_inference_jobs DROP COLUMN maybe_download_url;
@@ -0,0 +1,7 @@
-- noinspection SqlDialectInspectionForFile
-- noinspection SqlNoDataSourceInspectionForFile
-- noinspection SqlResolveForFile
ALTER TABLE generic_inference_jobs
ADD COLUMN maybe_download_url VARCHAR(1024) DEFAULT NULL
AFTER maybe_raw_inference_text;
@@ -0,0 +1,5 @@
-- noinspection SqlDialectInspectionForFile
-- noinspection SqlNoDataSourceInspectionForFile
-- noinspection SqlResolveForFile
ALTER TABLE generic_inference_jobs DROP COLUMN on_success_result_batch_token;
@@ -0,0 +1,7 @@
-- noinspection SqlDialectInspectionForFile
-- noinspection SqlNoDataSourceInspectionForFile
-- noinspection SqlResolveForFile
ALTER TABLE generic_inference_jobs
ADD COLUMN on_success_result_batch_token VARCHAR(32) DEFAULT NULL
AFTER on_success_result_entity_token;
@@ -72,6 +72,11 @@ CREATE TABLE generic_inference_jobs (
-- TEXT = 65,535 bytes (64 KiB), ~= 4 bytes per UTF-8 character, ~ 16383 characters.
maybe_raw_inference_text TEXT DEFAULT NULL,
-- For download-related jobs, this is the URL
-- This is nullable because not all inference jobs have a download URL.
-- The length of 1024 is arbitrary, but we shouldn't need anything longer.
maybe_download_url VARCHAR(1024) DEFAULT NULL,
-- ========== SUCCESS CASE ==========
-- The type of the object will vary based on the type of the upload,
@@ -82,6 +87,11 @@ CREATE TABLE generic_inference_jobs (
-- This is only populated on a successful result.
on_success_result_entity_token VARCHAR(32) DEFAULT NULL,
-- If the job completes successfully, this is the batch token (ie. when
-- several results are created).
-- Only populated if there are actual batches generated.
on_success_result_batch_token VARCHAR(32) DEFAULT NULL,
-- ========== CREATOR DETAILS AND PREFERENCES ==========
-- Foreign key to user
+8
View File
@@ -58,11 +58,15 @@ CREATE TABLE media_files (
-- The original filename of the media (if uploaded by a user)
maybe_origin_filename VARCHAR(255) DEFAULT NULL,
-- TODO: Remove after `maybe_batch_token` gains use.
-- Whether this media file was generated as part of a batch
-- If so, we can look up the batch in a separate query/call to the `batch_generations` table.
-- We won't hold the batch token in this table since it'll be very sparsely populated.
is_batch_generated BOOLEAN NOT NULL DEFAULT FALSE,
-- If the media file is generated as part of a batch, this designates the batch.
maybe_batch_token VARCHAR(32) DEFAULT NULL,
-- ========== METADATA ==========
-- We can store text transcripts, etc. in other tables and refer back via foreign key.
@@ -100,6 +104,9 @@ CREATE TABLE media_files (
-- For videos, the original frame height.
maybe_frame_height INT(5) DEFAULT NULL,
-- Optional text transcript for audio or video (especially TTS)
maybe_text_transcript TEXT DEFAULT NULL,
-- Checksum of the original media
-- SHA1 hash [SHA2 = CHAR(64), SHA1 = CHAR(40), MD5 = CHAR(32)]
-- checksum_sha1 CHAR(40) NOT NULL,
@@ -212,6 +219,7 @@ CREATE TABLE media_files (
KEY index_maybe_origin_model_type (maybe_origin_model_type),
KEY fk_maybe_origin_model_token (maybe_origin_model_token),
KEY fk_maybe_origin_model_type_and_token (maybe_origin_model_type, maybe_origin_model_token),
KEY index_maybe_batch_token (maybe_batch_token),
KEY index_media_type (media_type),
KEY index_checksum_sha2 (checksum_sha2),
KEY fk_maybe_creator_user_token (maybe_creator_user_token),
@@ -95,9 +95,8 @@ CREATE TABLE model_weights (
-- The filename that was used at upload time (if available)
original_filename VARCHAR(255) DEFAULT NULL,
-- TODO: Make this a BIGINT so we can store more than 2GB.
-- File characteristics
file_size_bytes INT(10) NOT NULL DEFAULT 0,
-- File size. BIGINT to store more than 2GB size.
file_size_bytes BIGINT(10) NOT NULL DEFAULT 0,
-- Checksum of the original weights file
-- SHA2 hash [SHA2 = CHAR(64), SHA1 = CHAR(40), MD5 = CHAR(32)]
@@ -181,7 +181,7 @@ fn raw_record_to_public_result(record: RawGenericInferenceJobStatus) -> GenericI
if let Some(title) = record.maybe_model_weights_title.as_deref() {
maybe_model_title = Some(title);
}
if maybe_model_title.is_none() {
maybe_model_title = match record.inference_category {
InferenceCategory::LipsyncAnimation => Some("lipsync animation"),