From f0cc541a716ca892f4772c022e8f4ac87fb38da0 Mon Sep 17 00:00:00 2001 From: Gavin D'souza Date: Tue, 17 Aug 2021 12:36:54 +0530 Subject: [PATCH] feat: Add util to convert compressed tables to DYNAMIC NOTE: This shouldn't be considered as a finished command. Only run this if you understand what you're doing --- frappe/commands/utils.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/frappe/commands/utils.py b/frappe/commands/utils.py index f2395ae490..54ee559cf5 100644 --- a/frappe/commands/utils.py +++ b/frappe/commands/utils.py @@ -512,6 +512,29 @@ def console(context): IPython.embed(display_banner="", header="", colors="neutral") +@click.command('convert-database') +@pass_context +def convert_database(context): + "convert row_formats to DNAMIC from older formats -- innodb mariadb v10.6.3" + site = get_site(context) + frappe.init(site=site) + frappe.connect() + + information_schema = frappe.qb.Schema("information_schema") + queried_tables = frappe.qb.from_( + information_schema.tables + ).select("table_name").where( + information_schema.tables.row_format=="Compressed" + ).run() + tables = [x[0] for x in queried_tables] + + for table in tables: + frappe.db.sql(f"ALTER TABLE `{table}` ROW_FORMAT=DYNAMIC") + + frappe.db.commit() + frappe.destroy() + + @click.command('run-tests') @click.option('--app', help="For App") @click.option('--doctype', help="For DocType") @@ -796,6 +819,7 @@ commands = [ build, clear_cache, clear_website_cache, + convert_database, jupyter, console, destroy_all_sessions,