diff --git a/backend/main.py b/backend/main.py index c37124f1e..8426536ef 100644 --- a/backend/main.py +++ b/backend/main.py @@ -173,11 +173,14 @@ https://github.com/open-webui/open-webui def run_migrations(): - from alembic.config import Config - from alembic import command + try: + from alembic.config import Config + from alembic import command - alembic_cfg = Config("alembic.ini") - command.upgrade(alembic_cfg, "head") + alembic_cfg = Config("alembic.ini") + command.upgrade(alembic_cfg, "head") + except Exception as e: + print(f"Error: {e}") @asynccontextmanager diff --git a/backend/migrations/env.py b/backend/migrations/env.py index c700c20f5..7035cf917 100644 --- a/backend/migrations/env.py +++ b/backend/migrations/env.py @@ -43,7 +43,7 @@ target_metadata = Auth.metadata DB_URL = DATABASE_URL if DB_URL: - config.set_main_option("sqlalchemy.url", DB_URL) + config.set_main_option("sqlalchemy.url", DB_URL.replace("%", "%%")) def run_migrations_offline() -> None: