Skip to content

Commit d71483a

Browse files
Coderabbit fixes 2
1 parent de43479 commit d71483a

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

backend/app/database/face_clusters.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ def db_create_clusters_table() -> None:
3434
)
3535
"""
3636
)
37+
cursor.execute(
38+
"CREATE UNIQUE INDEX IF NOT EXISTS idx_cluster_name ON face_clusters(cluster_name)"
39+
)
3740
conn.commit()
3841
finally:
3942
if conn is not None:
@@ -362,6 +365,11 @@ def db_get_or_create_cluster_by_name(name: str, cursor: Optional[sqlite3.Cursor]
362365
conn = cursor.connection
363366

364367
try:
368+
# Ensure unique index exists so INSERT OR IGNORE works as expected
369+
cursor.execute(
370+
"CREATE UNIQUE INDEX IF NOT EXISTS idx_cluster_name ON face_clusters(cluster_name)"
371+
)
372+
365373
cluster_id = str(uuid.uuid4())
366374
# Attempt to insert first (optimistic)
367375
cursor.execute(

0 commit comments

Comments
 (0)