From 908da9e9de1f3744286784d4f9e1c4610c2564a6 Mon Sep 17 00:00:00 2001 From: Automated Action Date: Mon, 12 May 2025 17:05:16 +0000 Subject: [PATCH] Fix database migration error MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Added missing pydantic-settings to requirements.txt - Fixed database path inconsistency between config.py and session.py - Updated alembic.ini to use proper SQLite URL format - Updated migrations/env.py to use config settings 🤖 Generated with BackendIM... (backend.im) Co-Authored-By: Claude --- alembic.ini | 2 +- app/core/config.py | 2 +- migrations/env.py | 4 ++++ requirements.txt | 1 + 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/alembic.ini b/alembic.ini index 03492bf..b7c6f7b 100644 --- a/alembic.ini +++ b/alembic.ini @@ -35,7 +35,7 @@ script_location = migrations # are written from script.py.mako # output_encoding = utf-8 -sqlalchemy.url = sqlite:///projects/userauthenticationflowservice-fvu111/storage/db/db.sqlite +sqlalchemy.url = sqlite:////projects/userauthenticationflowservice-fvu111/storage/db/db.sqlite [post_write_hooks] diff --git a/app/core/config.py b/app/core/config.py index 51d188a..80e72d2 100644 --- a/app/core/config.py +++ b/app/core/config.py @@ -30,7 +30,7 @@ class Settings(BaseSettings): DEBUG: bool = True # Database settings - DB_PATH: str = "/app/storage/db/db.sqlite" + DB_PATH: str = "/projects/userauthenticationflowservice-fvu111/storage/db/db.sqlite" SQLALCHEMY_DATABASE_URL: str = f"sqlite:///{DB_PATH}" # First superuser diff --git a/migrations/env.py b/migrations/env.py index 40d114d..7d15b68 100644 --- a/migrations/env.py +++ b/migrations/env.py @@ -9,6 +9,7 @@ from sqlalchemy import engine_from_config from sqlalchemy import pool from alembic import context +from app.core.config import settings # this is the Alembic Config object, which provides # access to the values within the .ini file in use. @@ -25,6 +26,9 @@ from app.models.user import User # Import all models here for Alembic to detect target_metadata = Base.metadata +# Override the sqlalchemy.url with the one from settings +config.set_main_option("sqlalchemy.url", settings.SQLALCHEMY_DATABASE_URL) + # other values from the config, defined by the needs of env.py, # can be acquired: # my_important_option = config.get_main_option("my_important_option") diff --git a/requirements.txt b/requirements.txt index 8bcbc97..e178a89 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,7 @@ fastapi==0.104.1 uvicorn==0.23.2 pydantic==2.4.2 +pydantic-settings==2.0.3 sqlalchemy==2.0.22 passlib==1.7.4 python-jose==3.3.0