From df12413c5d8b691178d0f3d3e101b83e6384b054 Mon Sep 17 00:00:00 2001 From: Ethanfel Date: Tue, 20 Jan 2026 13:23:34 +0100 Subject: [PATCH] Update engine.py --- engine.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/engine.py b/engine.py index 64f43c6..813fcdc 100644 --- a/engine.py +++ b/engine.py @@ -578,7 +578,18 @@ class SorterEngine: conn = sqlite3.connect(SorterEngine.DB_PATH) cursor = conn.cursor() - # Ensure table exists (for existing databases) + # Check if table exists and has correct schema + cursor.execute("SELECT name FROM sqlite_master WHERE type='table' AND name='folder_tags'") + if cursor.fetchone(): + # Table exists - check if it has the filename column + cursor.execute("PRAGMA table_info(folder_tags)") + columns = [row[1] for row in cursor.fetchall()] + if 'filename' not in columns: + # Wrong schema - drop and recreate + cursor.execute("DROP TABLE folder_tags") + conn.commit() + + # Create table with correct schema cursor.execute('''CREATE TABLE IF NOT EXISTS folder_tags (folder_path TEXT, filename TEXT, category TEXT, tag_index INTEGER, PRIMARY KEY (folder_path, filename))''')