fix(database): resolve foreign key constraint error

This commit is contained in:
Vito Sansevero
2025-05-25 21:36:48 -07:00
parent 7957227db8
commit e0ac927a0d
+3
View File
@@ -312,6 +312,9 @@ class PromptDatabase:
bool: True if deletion was successful, False otherwise
"""
with self.model.get_connection() as conn:
# First delete related images to avoid foreign key constraint
conn.execute("DELETE FROM generated_images WHERE prompt_id = ?", (prompt_id,))
# Then delete the prompt
cursor = conn.execute("DELETE FROM prompts WHERE id = ?", (prompt_id,))
conn.commit()
return cursor.rowcount > 0