refactor: qb in patch v13 increase_password_length

This commit is contained in:
saxenabhishek 2021-07-15 01:29:17 +05:30
parent 43b0d31cf8
commit 90cd4f708c
2 changed files with 9 additions and 4 deletions

View file

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

View file

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