From 95426fc6c9ec5ffafc675e4f4d3f5fe3bc727842 Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Mon, 8 Jul 2024 11:27:10 -0700 Subject: [PATCH] refac: do not use subprocess --- backend/main.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/backend/main.py b/backend/main.py index 2da19c5c7..c37124f1e 100644 --- a/backend/main.py +++ b/backend/main.py @@ -173,13 +173,11 @@ https://github.com/open-webui/open-webui def run_migrations(): - env = os.environ.copy() - env["DATABASE_URL"] = DATABASE_URL - migration_task = subprocess.run( - ["alembic", f"-c{BACKEND_DIR}/alembic.ini", "upgrade", "head"], env=env - ) - if migration_task.returncode > 0: - raise ValueError("Error running migrations") + from alembic.config import Config + from alembic import command + + alembic_cfg = Config("alembic.ini") + command.upgrade(alembic_cfg, "head") @asynccontextmanager