diff --git a/frappe/patches/v13_0/increase_password_length.py b/frappe/patches/v13_0/increase_password_length.py index 1bb1979051..3f0e93e72c 100644 --- a/frappe/patches/v13_0/increase_password_length.py +++ b/frappe/patches/v13_0/increase_password_length.py @@ -1,7 +1,4 @@ import frappe def execute(): - frappe.db.multisql({ - "mariadb": "ALTER TABLE `__Auth` MODIFY `password` TEXT NOT NULL", - "postgres": 'ALTER TABLE "__Auth" ALTER COLUMN "password" TYPE TEXT' - }) + frappe.db.sql(frappe.qb.change_table_type(tb = "__Auth",col = "password",type = "TEXT")) diff --git a/frappe/query_builder/qb.py b/frappe/query_builder/qb.py index d085c01027..ddf514ab2c 100644 --- a/frappe/query_builder/qb.py +++ b/frappe/query_builder/qb.py @@ -35,6 +35,10 @@ class MariaDB(MySQLQuery,common): def DESC(dt): return f"DESC `tab{dt}`" + @staticmethod + def change_table_type(tb, col, type): + return f"ALTER TABLE `{tb}` MODIFY `{col}` {type} NOT NULL" + class Postgres(PostgreSQLQuery,common): postgres_field = {"table_name": "relname", "table_rows": "n_tup_ins"} information_schema_translation = {"tables": "pg_stat_all_tables"} @@ -67,3 +71,7 @@ class Postgres(PostgreSQLQuery,common): @staticmethod def DESC(dt): return f"SELECT COLUMN_NAME FROM information_schema.COLUMNS WHERE TABLE_NAME = 'tab{dt}'" + + @staticmethod + def change_table_type(tb, col, type): + return f'ALTER TABLE "{tb}" ALTER COLUMN "{col}" TYPE {type}'