mirror of
https://github.com/open-webui/open-webui
synced 2024-11-16 05:24:02 +00:00
feat(sqlalchemy): use subprocess to do migrations
This commit is contained in:
parent
bee835cb65
commit
070d9083d5
@ -58,7 +58,7 @@ version_path_separator = os # Use os.pathsep. Default configuration used for ne
|
||||
# are written from script.py.mako
|
||||
# output_encoding = utf-8
|
||||
|
||||
sqlalchemy.url = REPLACE_WITH_DATABASE_URL
|
||||
# sqlalchemy.url = REPLACE_WITH_DATABASE_URL
|
||||
|
||||
|
||||
[post_write_hooks]
|
||||
|
@ -173,13 +173,11 @@ https://github.com/open-webui/open-webui
|
||||
|
||||
|
||||
def run_migrations():
|
||||
from alembic.config import Config
|
||||
from alembic import command
|
||||
|
||||
alembic_cfg = Config(f"{BACKEND_DIR}/alembic.ini")
|
||||
alembic_cfg.set_main_option("sqlalchemy.url", DATABASE_URL)
|
||||
alembic_cfg.set_main_option("script_location", f"{BACKEND_DIR}/migrations")
|
||||
command.upgrade(alembic_cfg, "head")
|
||||
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")
|
||||
|
||||
|
||||
@asynccontextmanager
|
||||
|
Loading…
Reference in New Issue
Block a user