From 4320b127d3990cbf27e7ab0e3bc07101764782c4 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Mon, 28 Aug 2023 14:43:58 -0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(utils.py):=20handle=20except?= =?UTF-8?q?ion=20when=20running=20migrations=20to=20ignore=20"already=20ex?= =?UTF-8?q?ists"=20error=20and=20prevent=20unnecessary=20error=20logging?= =?UTF-8?q?=20and=20raising=20of=20RuntimeError?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/langflow/services/database/utils.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/backend/langflow/services/database/utils.py b/src/backend/langflow/services/database/utils.py index efbf2b2c8..47204e14d 100644 --- a/src/backend/langflow/services/database/utils.py +++ b/src/backend/langflow/services/database/utils.py @@ -33,8 +33,11 @@ def initialize_database(): session.execute("DROP TABLE alembic_version") database_manager.run_migrations() except Exception as exc: - logger.error(f"Error running migrations: {exc}") - raise RuntimeError("Error running migrations") from exc + # if the exception involves tables already existing + # we can ignore it + if "already exists" not in str(exc): + logger.error(f"Error running migrations: {exc}") + raise RuntimeError("Error running migrations") from exc database_manager.create_db_and_tables() logger.debug("Database initialized")