Files
ImageApi/migrations/2026-10-30-100000_add_enhance_jobs/up.sql
T

32 lines
1.5 KiB
SQL

-- Enhance on demand (#192): one row per ComfyUI run submitted for a photo.
--
-- Keyed to the photo by `original_hash` (the blake3 content_hash of the file
-- that was submitted), like every other derived table, so a job survives a
-- rename or move; `library_id` + `rel_path` say which file it was at submit
-- time (and are what the API echoes back as `path`).
CREATE TABLE enhance_jobs (
id TEXT PRIMARY KEY NOT NULL, -- uuid, ImageApi's own
original_hash TEXT NOT NULL,
library_id INTEGER NOT NULL,
rel_path TEXT NOT NULL,
template TEXT NOT NULL,
prompt TEXT,
reference_hash TEXT,
reference_path TEXT, -- library-relative, same library
comfy_prompt_id TEXT NOT NULL,
-- queued | running | ready | approved | failed | expired | unavailable
status TEXT NOT NULL,
error TEXT,
queue_position INTEGER,
-- json: [{id, view: {filename, subfolder, type}}], ComfyUI's staged results
pending TEXT NOT NULL DEFAULT '[]',
-- json: [{n, comfy_path, library_id, rel_path}], approved results
saved TEXT NOT NULL DEFAULT '[]',
-- 1 = the user threw the result away; hidden from the per-photo list
discarded INTEGER NOT NULL DEFAULT 0,
created_at BIGINT NOT NULL,
updated_at BIGINT NOT NULL
);
CREATE INDEX idx_enhance_jobs_hash ON enhance_jobs(original_hash, created_at);
CREATE INDEX idx_enhance_jobs_status ON enhance_jobs(status);