From c2506a9e3ff98fa57b4b27203fba196c88895c69 Mon Sep 17 00:00:00 2001 From: Automated Action Date: Mon, 12 May 2025 12:36:07 +0000 Subject: [PATCH] Fix Alembic migration error by adding project root to Python path and updating Pydantic config - Added project root directory to Python path in alembic/env.py - Updated Pydantic Settings class to use ClassVar typing for DB_DIR - Updated Config class to new Pydantic v2 model_config format generated with BackendIM... (backend.im) --- alembic/env.py | 5 +++++ app/core/config.py | 13 +++++++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/alembic/env.py b/alembic/env.py index a8c29ba..69250bb 100644 --- a/alembic/env.py +++ b/alembic/env.py @@ -1,4 +1,9 @@ from logging.config import fileConfig +import os +import sys + +# Add the project root directory to the Python path +sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) from sqlalchemy import engine_from_config from sqlalchemy import pool diff --git a/app/core/config.py b/app/core/config.py index 54ec258..ca5be0d 100644 --- a/app/core/config.py +++ b/app/core/config.py @@ -1,5 +1,5 @@ from pathlib import Path -from typing import List +from typing import List, ClassVar from pydantic_settings import BaseSettings @@ -18,7 +18,7 @@ class Settings(BaseSettings): JWT_ACCESS_TOKEN_EXPIRE_MINUTES: int = 30 # Database - DB_DIR = Path("/app") / "storage" / "db" + DB_DIR: ClassVar[Path] = Path("/app") / "storage" / "db" DB_DIR.mkdir(parents=True, exist_ok=True) SQLALCHEMY_DATABASE_URL: str = f"sqlite:///{DB_DIR}/db.sqlite" @@ -26,10 +26,11 @@ class Settings(BaseSettings): STRIPE_API_KEY: str = "your-stripe-api-key" STRIPE_WEBHOOK_SECRET: str = "your-stripe-webhook-secret" - class Config: - env_file = ".env" - env_file_encoding = "utf-8" - case_sensitive = True + model_config = { + "env_file": ".env", + "env_file_encoding": "utf-8", + "case_sensitive": True + } settings = Settings() \ No newline at end of file