Fix alembic migration issues by adding project to Python path and fixing pydantic config
generated with BackendIM... (backend.im)
This commit is contained in:
parent
b5b524e11f
commit
fd962ad54c
@ -1,4 +1,9 @@
|
||||
from logging.config import fileConfig
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
# Add the project root directory to Python's path
|
||||
sys.path.insert(0, str(Path(__file__).parent.parent))
|
||||
|
||||
from sqlalchemy import engine_from_config
|
||||
from sqlalchemy import pool
|
||||
@ -6,7 +11,7 @@ from sqlalchemy import pool
|
||||
from alembic import context
|
||||
|
||||
from app.core.config import settings
|
||||
from app.models import Base
|
||||
from app.core.database import Base
|
||||
|
||||
# this is the Alembic Config object, which provides
|
||||
# access to the values within the .ini file in use.
|
||||
|
@ -1,16 +1,19 @@
|
||||
import os
|
||||
from pathlib import Path
|
||||
from typing import Optional
|
||||
from typing import Optional, ClassVar
|
||||
from pydantic_settings import BaseSettings
|
||||
|
||||
# Create DB directory path
|
||||
DB_PATH = Path("/projects/weatherdataapi-2z0ghm") / "app" / "storage" / "db"
|
||||
DB_PATH.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
class Settings(BaseSettings):
|
||||
API_V1_STR: str = "/api/v1"
|
||||
PROJECT_NAME: str = "Weather Data API"
|
||||
|
||||
# Database configuration
|
||||
DB_DIR = Path("/app") / "storage" / "db"
|
||||
DB_DIR.mkdir(parents=True, exist_ok=True)
|
||||
SQLALCHEMY_DATABASE_URL: str = f"sqlite:///{DB_DIR}/db.sqlite"
|
||||
DB_DIR: ClassVar[Path] = DB_PATH
|
||||
SQLALCHEMY_DATABASE_URL: str = f"sqlite:///{DB_PATH}/db.sqlite"
|
||||
|
||||
# OpenWeatherMap API configuration
|
||||
OPENWEATHERMAP_API_KEY: Optional[str] = os.getenv("OPENWEATHERMAP_API_KEY")
|
||||
|
Loading…
x
Reference in New Issue
Block a user