From 7cef391c68ab571fd14b08575d38adfd85950705 Mon Sep 17 00:00:00 2001 From: Automated Action Date: Tue, 17 Jun 2025 05:55:17 +0000 Subject: [PATCH] Fix database migration error by adding missing dependency - Added pydantic-settings>=2.0.0 to requirements.txt to resolve ModuleNotFoundError - Simplified migrations/env.py imports to avoid config dependency issues - Removed unnecessary settings import from migration environment - Migration now uses database URL directly from alembic.ini configuration --- app/crud/todo.py | 4 +--- migrations/env.py | 6 ++++-- requirements.txt | 1 + 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/app/crud/todo.py b/app/crud/todo.py index c3e70c7..dac9631 100644 --- a/app/crud/todo.py +++ b/app/crud/todo.py @@ -34,9 +34,7 @@ class CRUDTodo: if completed is not None: filters.append(Todo.completed == completed) if overdue_only: - filters.append( - and_(Todo.due_date < datetime.now(), not_(Todo.completed)) - ) + filters.append(and_(Todo.due_date < datetime.now(), not_(Todo.completed))) if filters: query = query.filter(and_(*filters)) diff --git a/migrations/env.py b/migrations/env.py index e134b75..327ff3a 100644 --- a/migrations/env.py +++ b/migrations/env.py @@ -7,11 +7,13 @@ from sqlalchemy import engine_from_config, pool from alembic import context # Add the project root directory to the Python path -sys.path.append(str(Path(__file__).resolve().parent.parent)) +project_root = Path(__file__).resolve().parent.parent +sys.path.insert(0, str(project_root)) # Import Base from app.db.base from app.db.base_model import Base # noqa -from app.core.config import settings # noqa + +# No need to import settings since we use alembic.ini database URL # this is the Alembic Config object, which provides # access to the values within the .ini file in use. diff --git a/requirements.txt b/requirements.txt index a4eca1d..9ea4399 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,6 +3,7 @@ uvicorn>=0.23.2 sqlalchemy>=2.0.0 pydantic>=2.4.2 pydantic[email]>=2.4.2 +pydantic-settings>=2.0.0 alembic>=1.12.0 python-dotenv>=1.0.0 ruff>=0.1.3 \ No newline at end of file