perf: Single query to update a table

This commit is contained in:
Gavin D'souza 2021-09-02 15:51:49 +05:30
parent b88eca73c3
commit 71dc7f474f

View file

@ -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