From 50cc0035d9b7ce57103341dde4d04bbb73aa17e8 Mon Sep 17 00:00:00 2001 From: Christian Krakau-Louis Date: Wed, 11 Feb 2026 22:39:21 +0100 Subject: [PATCH] feat(database): add file path columns to files table during migration fix(general): update processed files count query to use FileRecord.id chore: add VSCode settings for pytest configuration --- .vscode/settings.json | 7 +++++++ app/database.py | 15 +++++++++++++++ app/views/general.py | 2 +- 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..9b388533 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "python.testing.pytestArgs": [ + "tests" + ], + "python.testing.unittestEnabled": false, + "python.testing.pytestEnabled": true +} \ No newline at end of file diff --git a/app/database.py b/app/database.py index 56b3f835..89c7661d 100644 --- a/app/database.py +++ b/app/database.py @@ -74,6 +74,21 @@ def _run_schema_migrations(engine): conn.execute(text("ALTER TABLE processing_logs ADD COLUMN detail TEXT")) logger.info("Migration complete: 'detail' column added to processing_logs") + # Migration: Add file path columns to files table + if "files" in inspector.get_table_names(): + columns = [col["name"] for col in inspector.get_columns("files")] + if "original_file_path" not in columns: + logger.info("Migrating files: adding 'original_file_path' column") + with engine.begin() as conn: + conn.execute(text("ALTER TABLE files ADD COLUMN original_file_path VARCHAR")) + logger.info("Migration complete: 'original_file_path' column added to files") + + if "processed_file_path" not in columns: + logger.info("Migrating files: adding 'processed_file_path' column") + with engine.begin() as conn: + conn.execute(text("ALTER TABLE files ADD COLUMN processed_file_path VARCHAR")) + logger.info("Migration complete: 'processed_file_path' column added to files") + def get_db(): """ diff --git a/app/views/general.py b/app/views/general.py index 6f4d62ae..e22d86e7 100644 --- a/app/views/general.py +++ b/app/views/general.py @@ -57,7 +57,7 @@ async def serve_index(request: Request, db: Session = Depends(get_db)): # Import the model here to avoid circular imports from app.models import FileRecord - processed_files = db.query(FileRecord).count() + processed_files = db.query(FileRecord.id).count() except Exception as e: # Log error but continue (don't break the page if DB query fails) logger.error(f"Error counting files: {str(e)}")