From 27ca3b0555865885ae5e973088f9c7d92a23a7f6 Mon Sep 17 00:00:00 2001 From: Vito Sansevero Date: Sun, 25 May 2025 21:37:02 -0700 Subject: [PATCH] fix(api): fix foreign key constraint error deletion --- py/api.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/py/api.py b/py/api.py index 80aa28b..0318cb4 100644 --- a/py/api.py +++ b/py/api.py @@ -738,6 +738,9 @@ class PromptManagerAPI: deleted_count = 0 with self.db.model.get_connection() as conn: for prompt_id in prompt_ids: + # 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,) )