Skip to content

Commit

Permalink
Added app_start function to call alembic scripts (#37)
Browse files Browse the repository at this point in the history
Closes #36
  • Loading branch information
jcadam14 authored Jan 24, 2024
1 parent c8e7743 commit 7995c00
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/main.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,22 @@
import os

from fastapi import FastAPI

from routers import filing_router

from alembic.config import Config
from alembic import command

app = FastAPI()


@app.on_event("startup")
async def app_start():
file_dir = os.path.dirname(os.path.realpath(__file__))
alembic_cfg = Config(f"{file_dir}/../alembic.ini")
alembic_cfg.set_main_option("script_location", f"{file_dir}/../db_revisions")
alembic_cfg.set_main_option("prepend_sys_path", f"{file_dir}/../")
command.upgrade(alembic_cfg, "head")


app.include_router(filing_router, prefix="/v1/filing")

0 comments on commit 7995c00

Please sign in to comment.