This commit is contained in:
mike
2026-06-20 04:44:35 +02:00
parent f49af6b33a
commit cfb2e45f1f
21 changed files with 4579 additions and 273 deletions

View File

@@ -26,6 +26,8 @@ def migrate_schema():
"ALTER TABLE person ADD COLUMN IF NOT EXISTS has_background BOOLEAN DEFAULT TRUE",
"ALTER TABLE person ADD COLUMN IF NOT EXISTS source_refs TEXT",
"ALTER TABLE person ADD COLUMN IF NOT EXISTS has_clothing BOOLEAN DEFAULT NULL",
"ALTER TABLE person ADD COLUMN IF NOT EXISTS content_type TEXT DEFAULT 'image'",
"ALTER TABLE person ADD COLUMN IF NOT EXISTS faceswap_source_video TEXT",
]:
cur.execute(sql)
conn.commit()
@@ -36,34 +38,39 @@ def migrate_schema():
def upsert_person(filename, filepath=None, name=None, group_id=None, tags=None,
embedding=None, clip_description=None, prompt=None, pose=None,
sort_order=None, group_name=None, hidden=None,
has_background=None, source_refs=None, has_clothing=None):
has_background=None, source_refs=None, has_clothing=None,
content_type=None, faceswap_source_video=None):
conn = get_db_connection()
cur = conn.cursor()
try:
cur.execute("""
INSERT INTO person (filename, filepath, name, group_id, tags, embedding,
clip_description, prompt, pose, sort_order, group_name, hidden,
has_background, source_refs, has_clothing)
VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)
has_background, source_refs, has_clothing,
content_type, faceswap_source_video)
VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)
ON CONFLICT (filename) DO UPDATE
SET filepath = COALESCE(EXCLUDED.filepath, person.filepath),
name = COALESCE(EXCLUDED.name, person.name),
group_id = COALESCE(EXCLUDED.group_id, person.group_id),
tags = COALESCE(EXCLUDED.tags, person.tags),
embedding = COALESCE(EXCLUDED.embedding, person.embedding),
clip_description= COALESCE(EXCLUDED.clip_description,person.clip_description),
prompt = COALESCE(EXCLUDED.prompt, person.prompt),
pose = COALESCE(EXCLUDED.pose, person.pose),
sort_order = COALESCE(EXCLUDED.sort_order, person.sort_order),
group_name = COALESCE(EXCLUDED.group_name, person.group_name),
hidden = COALESCE(EXCLUDED.hidden, person.hidden),
has_background = COALESCE(EXCLUDED.has_background, person.has_background),
source_refs = COALESCE(EXCLUDED.source_refs, person.source_refs),
has_clothing = COALESCE(EXCLUDED.has_clothing, person.has_clothing);
SET filepath = COALESCE(EXCLUDED.filepath, person.filepath),
name = COALESCE(EXCLUDED.name, person.name),
group_id = COALESCE(EXCLUDED.group_id, person.group_id),
tags = COALESCE(EXCLUDED.tags, person.tags),
embedding = COALESCE(EXCLUDED.embedding, person.embedding),
clip_description = COALESCE(EXCLUDED.clip_description, person.clip_description),
prompt = COALESCE(EXCLUDED.prompt, person.prompt),
pose = COALESCE(EXCLUDED.pose, person.pose),
sort_order = COALESCE(EXCLUDED.sort_order, person.sort_order),
group_name = COALESCE(EXCLUDED.group_name, person.group_name),
hidden = COALESCE(EXCLUDED.hidden, person.hidden),
has_background = COALESCE(EXCLUDED.has_background, person.has_background),
source_refs = COALESCE(EXCLUDED.source_refs, person.source_refs),
has_clothing = COALESCE(EXCLUDED.has_clothing, person.has_clothing),
content_type = COALESCE(EXCLUDED.content_type, person.content_type),
faceswap_source_video = COALESCE(EXCLUDED.faceswap_source_video, person.faceswap_source_video);
""", (filename, filepath, name, group_id,
json.dumps(tags) if tags else None,
embedding, clip_description, prompt, pose, sort_order, group_name, hidden,
has_background, source_refs, has_clothing))
has_background, source_refs, has_clothing,
content_type, faceswap_source_video))
conn.commit()
finally:
cur.close()
@@ -101,7 +108,7 @@ def list_persons():
cur.execute("""
SELECT filename, name, group_id, clip_description,
prompt, pose, sort_order, group_name, hidden, has_background, source_refs,
has_clothing
has_clothing, content_type, faceswap_source_video
FROM person
""")
return cur.fetchall()