From 71dc7f474ff695839de253d41b95bef11fa98ad2 Mon Sep 17 00:00:00 2001 From: Gavin D'souza Date: Thu, 2 Sep 2021 15:51:49 +0530 Subject: [PATCH] perf: Single query to update a table --- frappe/commands/utils.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/frappe/commands/utils.py b/frappe/commands/utils.py index 2dba0dd678..bad26944b6 100644 --- a/frappe/commands/utils.py +++ b/frappe/commands/utils.py @@ -583,13 +583,14 @@ def transform_database(context, table, engine, row_format, failfast): total = len(tables) for current, table in enumerate(tables): + values_to_set = "" + if engine: + values_to_set += f" ENGINE={engine}" + if row_format: + values_to_set += f" ROW_FORMAT={row_format}" + try: - if engine: - frappe.db.sql(f"ALTER TABLE `{table}` ENGINE={engine}") - - if row_format: - frappe.db.sql(f"ALTER TABLE `{table}` ROW_FORMAT={row_format}") - + frappe.db.sql(f"ALTER TABLE `{table}`{values_to_set}") update_progress_bar("Updating table schema", current - skipped, total) add_line = True