diff --git a/database/operations.py b/database/operations.py index 78293e7..e467bfe 100644 --- a/database/operations.py +++ b/database/operations.py @@ -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