mirror of
https://github.com/frappe/frappe.git
synced 2024-06-03 00:10:47 +00:00
refactor: add_column (#24867)
- Skip cache which can be invalid - Do check at db level
This commit is contained in:
parent
7b197f1a2b
commit
4350f94616
|
@ -391,13 +391,8 @@ def get_definition(fieldtype, precision=None, length=None):
|
|||
|
||||
|
||||
def add_column(doctype, column_name, fieldtype, precision=None, length=None, default=None, not_null=False):
|
||||
if column_name in frappe.db.get_table_columns(doctype):
|
||||
# already exists
|
||||
return
|
||||
|
||||
frappe.db.commit()
|
||||
|
||||
query = "alter table `tab{}` add column {} {}".format(
|
||||
query = "alter table `tab{}` add column if not exists {} {}".format(
|
||||
doctype,
|
||||
column_name,
|
||||
get_definition(fieldtype, precision, length),
|
||||
|
|
|
@ -76,6 +76,7 @@ class SiteMigration:
|
|||
"""Complete setup required for site migration"""
|
||||
frappe.flags.touched_tables = set()
|
||||
self.touched_tables_file = frappe.get_site_path("touched_tables.json")
|
||||
frappe.clear_cache()
|
||||
add_column(doctype="DocType", column_name="migration_hash", fieldtype="Data")
|
||||
clear_global_cache()
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user