diff --git a/frappe/custom/doctype/custom_field/custom_field.py b/frappe/custom/doctype/custom_field/custom_field.py index ea377bc23d2..79ee129203d 100644 --- a/frappe/custom/doctype/custom_field/custom_field.py +++ b/frappe/custom/doctype/custom_field/custom_field.py @@ -258,7 +258,8 @@ def rename_fieldname(custom_field: str, fieldname: str): frappe.msgprint(_("Old and new fieldnames are same."), alert=True) return - frappe.db.rename_column(parent_doctype, old_fieldname, new_fieldname) + if frappe.db.has_column(field.dt, old_fieldname): + frappe.db.rename_column(parent_doctype, old_fieldname, new_fieldname) # Update in DB after alter column is successful, alter column will implicitly commit, so it's # best to commit change on field too to avoid any possible mismatch between two.