feat: snapshot product suite reference assets

This commit is contained in:
chengma
2026-07-17 17:03:40 +08:00
parent d11dc752b5
commit 1fabd8afcf
12 changed files with 252 additions and 5 deletions
+12
View File
@@ -338,6 +338,7 @@ CREATE TABLE IF NOT EXISTS image_studio_jobs (
id INTEGER PRIMARY KEY,
project_id INTEGER NOT NULL REFERENCES image_studio_projects(id) ON DELETE CASCADE,
source_asset_id INTEGER REFERENCES image_studio_assets(id) ON DELETE SET NULL,
reference_asset_ids TEXT,
output_asset_id INTEGER REFERENCES image_studio_assets(id) ON DELETE SET NULL,
generation_source TEXT NOT NULL DEFAULT 'cmhub',
provider TEXT NOT NULL DEFAULT 'cmhub',
@@ -488,6 +489,7 @@ def init_db(path=None, conn=None) -> None:
_ensure_image_studio_project_draft_columns(database)
_ensure_image_studio_job_recovery_columns(database)
_ensure_image_studio_generation_round_columns(database)
_ensure_image_studio_job_reference_asset_ids_column(database)
def _ensure_batch_delete_columns(database):
@@ -612,6 +614,16 @@ def _ensure_image_studio_generation_round_columns(database):
"project_id, generation_round_key, generation_slot_index, id)"
)
def _ensure_image_studio_job_reference_asset_ids_column(database):
columns = {
row["name"] for row in database.execute("PRAGMA table_info(image_studio_jobs)").fetchall()
}
if "reference_asset_ids" not in columns:
database.execute(
"ALTER TABLE image_studio_jobs ADD COLUMN reference_asset_ids TEXT"
)
def create_batch(file_paths: Iterable[str], note=None, path=None, conn=None) -> str:
batch_id = datetime.now().strftime("%Y%m%d_%H%M%S_") + uuid.uuid4().hex[:8]
files = [os.path.abspath(file_path) for file_path in file_paths]