fix(database): resolve foreign key constraint error
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user