From e0ac927a0d061603e1b38cf8aa47bd51926ac6d9 Mon Sep 17 00:00:00 2001 From: Vito Sansevero Date: Sun, 25 May 2025 21:36:48 -0700 Subject: [PATCH] fix(database): resolve foreign key constraint error --- database/operations.py | 3 +++ 1 file changed, 3 insertions(+) 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