Patch: change default fields like name, owner, etc to varchar(255)
This commit is contained in:
parent
4ae43539c9
commit
9d6450d69b
3 changed files with 26 additions and 2 deletions
|
|
@ -77,8 +77,8 @@ class DbTable:
|
|||
name varchar(255) not null primary key,
|
||||
creation datetime(6),
|
||||
modified datetime(6),
|
||||
modified_by varchar(40),
|
||||
owner varchar(60),
|
||||
modified_by varchar(255),
|
||||
owner varchar(255),
|
||||
docstatus int(1) default '0',
|
||||
parent varchar(255),
|
||||
parentfield varchar(255),
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ execute:frappe.reload_doc('core', 'doctype', 'report') #2014-06-03
|
|||
execute:frappe.reload_doc('core', 'doctype', 'version') #2014-02-21
|
||||
execute:frappe.db.sql("alter table `tabSessions` modify `user` varchar(255), engine=InnoDB")
|
||||
execute:frappe.db.sql("delete from `tabDocField` where parent='0'")
|
||||
frappe.patches.v4_0.change_varchar_length
|
||||
|
||||
frappe.patches.v4_0.webnotes_to_frappe
|
||||
execute:frappe.reset_perms("Module Def")
|
||||
|
|
|
|||
23
frappe/patches/v4_0/change_varchar_length.py
Normal file
23
frappe/patches/v4_0/change_varchar_length.py
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||
# MIT License. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
|
||||
def execute():
|
||||
for dt in frappe.db.sql_list("""select name from `tabDocType` where ifnull(issingle, 0)=0"""):
|
||||
desc = dict((d["Field"], d) for d in frappe.db.sql("desc `tab{}`".format(dt), as_dict=True))
|
||||
alter_table = []
|
||||
|
||||
if desc["name"]["Type"] != "varchar(255)":
|
||||
alter_table.append("change `name` `name` varchar(255) not null primary key")
|
||||
|
||||
for fieldname in ("modified_by", "owner", "parent", "parentfield", "parenttype"):
|
||||
if desc[fieldname]["Type"] != "varchar(255)":
|
||||
alter_table.append("change `{fieldname}` `{fieldname}` varchar(255)".format(fieldname=fieldname))
|
||||
|
||||
if alter_table:
|
||||
alter_table_query = "alter table `tab{doctype}` {alter_table}".format(doctype=dt, alter_table=",\n".join(alter_table))
|
||||
# print alter_table_query
|
||||
frappe.db.sql_ddl(alter_table_query)
|
||||
|
||||
Loading…
Add table
Reference in a new issue