From dc559e61ae7e84cda481ddc3b0fca052cecc1270 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Tue, 3 Oct 2023 17:39:50 -0300 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=90=9B=20fix(manager.py):=20refactor?= =?UTF-8?q?=20create=5Fdb=5Fand=5Ftables=20method=20to=20check=20if=20data?= =?UTF-8?q?base=20and=20tables=20already=20exist=20before=20creating=20the?= =?UTF-8?q?m?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/langflow/services/database/manager.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/backend/langflow/services/database/manager.py b/src/backend/langflow/services/database/manager.py index 8b9dde7bd..18364cd62 100644 --- a/src/backend/langflow/services/database/manager.py +++ b/src/backend/langflow/services/database/manager.py @@ -154,6 +154,14 @@ class DatabaseService(Service): return results def create_db_and_tables(self): + from sqlalchemy import inspect + + inspector = inspect(self.engine) + current_tables = ["flow", "user", "apikey"] + table_names = inspector.get_table_names() + if table_names and all(table in table_names for table in current_tables): + logger.debug("Database and tables already exist") + return logger.debug("Creating database and tables") try: SQLModel.metadata.create_all(self.engine) @@ -163,10 +171,6 @@ class DatabaseService(Service): # Now check if the table "flow" exists, if not, something went wrong # and we need to create the tables again. - from sqlalchemy import inspect - - inspector = inspect(self.engine) - current_tables = ["flow", "user", "apikey"] table_names = inspector.get_table_names() for table in current_tables: if table not in table_names: From bf512e6636c35a1fd32048e9d008f29dd54ee5cc Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Tue, 3 Oct 2023 17:40:25 -0300 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=94=96=20chore(pyproject.toml):=20bum?= =?UTF-8?q?p=20version=20from=200.5.0a5=20to=200.5.0a6=20for=20package=20r?= =?UTF-8?q?elease?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index aabbe24a8..17f97b2ce 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "langflow" -version = "0.5.0a5" +version = "0.5.0a6" description = "A Python package with a built-in web application" authors = ["Logspace "] maintainers = [