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)
This commit is contained in:
parent
abc7a8572f
commit
c2506a9e3f
@ -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
|
||||
|
@ -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()
|
Loading…
x
Reference in New Issue
Block a user