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
This commit is contained in:
Vendored
+7
@@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"python.testing.pytestArgs": [
|
||||||
|
"tests"
|
||||||
|
],
|
||||||
|
"python.testing.unittestEnabled": false,
|
||||||
|
"python.testing.pytestEnabled": true
|
||||||
|
}
|
||||||
@@ -74,6 +74,21 @@ def _run_schema_migrations(engine):
|
|||||||
conn.execute(text("ALTER TABLE processing_logs ADD COLUMN detail TEXT"))
|
conn.execute(text("ALTER TABLE processing_logs ADD COLUMN detail TEXT"))
|
||||||
logger.info("Migration complete: 'detail' column added to processing_logs")
|
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():
|
def get_db():
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ async def serve_index(request: Request, db: Session = Depends(get_db)):
|
|||||||
# Import the model here to avoid circular imports
|
# Import the model here to avoid circular imports
|
||||||
from app.models import FileRecord
|
from app.models import FileRecord
|
||||||
|
|
||||||
processed_files = db.query(FileRecord).count()
|
processed_files = db.query(FileRecord.id).count()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
# Log error but continue (don't break the page if DB query fails)
|
# Log error but continue (don't break the page if DB query fails)
|
||||||
logger.error(f"Error counting files: {str(e)}")
|
logger.error(f"Error counting files: {str(e)}")
|
||||||
|
|||||||
Reference in New Issue
Block a user