Skip to content

Commit

Permalink
log
Browse files Browse the repository at this point in the history
  • Loading branch information
BeatrixCohere committed Aug 7, 2024
1 parent c42bcdf commit b931d52
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/backend/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
from backend.services.context import ContextMiddleware, get_context
from backend.services.logger.middleware import LoggingMiddleware
from backend.services.metrics import MetricsMiddleware
from structlog import get_logger

load_dotenv()

Expand Down Expand Up @@ -128,23 +129,19 @@ async def health():


@app.post("/migrate")
async def apply_migrations(request: Request):
async def apply_migrations():
"""
Applies Alembic migrations - useful for serverless applications
"""
try:
alembic_cfg = Config("src/backend/alembic.ini")
upgrade(alembic_cfg, "head")
except Exception as e:
ctx = get_context(request)
logger = ctx.get_logger()
logger = get_logger()

logger.exception(
event="Error while applying Alembic migrations",
error=str(e),
method=request.method,
url=request.url,
ctx=ctx,
)
raise HTTPException(
status_code=500, detail=f"Error while applying Alembic migrations: {str(e)}"
Expand Down

0 comments on commit b931d52

Please sign in to comment.