feat(product-suite): support temporary item drafts
This commit is contained in:
@@ -296,6 +296,8 @@ CREATE TABLE IF NOT EXISTS image_studio_projects (
|
||||
account_slug TEXT NOT NULL,
|
||||
account_name TEXT,
|
||||
item_id TEXT NOT NULL,
|
||||
storage_key TEXT NOT NULL,
|
||||
binding_state TEXT NOT NULL DEFAULT 'bound',
|
||||
target_main_count INTEGER NOT NULL DEFAULT 9,
|
||||
target_detail_count INTEGER NOT NULL DEFAULT 12,
|
||||
draft_prompt TEXT,
|
||||
@@ -480,6 +482,7 @@ def init_db(path=None, conn=None) -> None:
|
||||
_ensure_task_image_task_columns(database)
|
||||
_ensure_task_cover_reset_columns(database)
|
||||
_ensure_image_studio_project_suite_columns(database)
|
||||
_ensure_image_studio_project_draft_columns(database)
|
||||
_ensure_image_studio_job_recovery_columns(database)
|
||||
|
||||
|
||||
@@ -519,6 +522,32 @@ def _ensure_image_studio_project_suite_columns(database):
|
||||
)
|
||||
|
||||
|
||||
def _ensure_image_studio_project_draft_columns(database):
|
||||
columns = {
|
||||
row["name"]
|
||||
for row in database.execute("PRAGMA table_info(image_studio_projects)").fetchall()
|
||||
}
|
||||
if "storage_key" not in columns:
|
||||
database.execute("ALTER TABLE image_studio_projects ADD COLUMN storage_key TEXT")
|
||||
if "binding_state" not in columns:
|
||||
database.execute(
|
||||
"ALTER TABLE image_studio_projects "
|
||||
"ADD COLUMN binding_state TEXT NOT NULL DEFAULT 'bound'"
|
||||
)
|
||||
database.execute(
|
||||
"UPDATE image_studio_projects SET storage_key = item_id "
|
||||
"WHERE storage_key IS NULL OR TRIM(storage_key) = ''"
|
||||
)
|
||||
database.execute(
|
||||
"UPDATE image_studio_projects SET binding_state = 'bound' "
|
||||
"WHERE binding_state IS NULL OR binding_state NOT IN ('draft', 'bound')"
|
||||
)
|
||||
database.execute(
|
||||
"CREATE INDEX IF NOT EXISTS idx_image_studio_projects_binding "
|
||||
"ON image_studio_projects(binding_state, updated_at DESC)"
|
||||
)
|
||||
|
||||
|
||||
def _ensure_image_studio_job_recovery_columns(database):
|
||||
columns = {
|
||||
row["name"] for row in database.execute("PRAGMA table_info(image_studio_jobs)").fetchall()
|
||||
|
||||
Reference in New Issue
Block a user