diff --git a/src/backend/base/langflow/services/database/service.py b/src/backend/base/langflow/services/database/service.py index 63892797c18..34dc234b4c7 100644 --- a/src/backend/base/langflow/services/database/service.py +++ b/src/backend/base/langflow/services/database/service.py @@ -44,6 +44,11 @@ def __init__(self, settings_service: SettingsService): self.script_location = langflow_dir / "alembic" self.alembic_cfg_path = langflow_dir / "alembic.ini" self.engine = self._create_engine() + if self.settings_service.settings.alembic_log_file.startswith('/'): + # Then, the log file path is overridden by an absolute path, and we should use it directly. + self.alembic_log_path = Path(self.settings_service.settings.alembic_log_file) + else: + self.alembic_log_path = Path(f"{langflow_dir}/{self.settings_service.settings.alembic_log_file}") def reload_engine(self) -> None: self.engine = self._create_engine() @@ -178,7 +183,7 @@ def run_migrations(self, *, fix=False) -> None: # which is a buffer # I don't want to output anything # subprocess.DEVNULL is an int - with (self.script_location / "alembic.log").open("w", encoding="utf-8") as buffer: + with self.alembic_log_path.open("w", encoding="utf-8") as buffer: alembic_cfg = Config(stdout=buffer) # alembic_cfg.attributes["connection"] = session alembic_cfg.set_main_option("script_location", str(self.script_location)) diff --git a/src/backend/base/langflow/services/settings/base.py b/src/backend/base/langflow/services/settings/base.py index cdbdccde317..17e6e713418 100644 --- a/src/backend/base/langflow/services/settings/base.py +++ b/src/backend/base/langflow/services/settings/base.py @@ -157,6 +157,8 @@ class Settings(BaseSettings): """The log level for Langflow.""" log_file: str | None = "logs/langflow.log" """The path to log file for Langflow.""" + alembic_log_file: str | None = "alembic/alembic.log" + """The path to log file for Alembic for SQLAlchemy.""" frontend_path: str | None = None """The path to the frontend directory containing build files. This is for development purposes only..""" open_browser: bool = False