Closed melgo-tb closed 2 months ago
Updating the patch to check for columns before setting them seems to have fixed the issue for me
import frappe
def execute():
# Ensure the columns exist
ensure_columns_exist()
doc = frappe.qb.DocType("Company Print Options")
(
frappe.qb.update(doc)
.set(doc.print_label, doc.autofield)
.set(doc.print_value, doc.autofield_value)
.run()
)
def ensure_columns_exist():
# Check if the 'autofield' column exists and add it if it doesn't
if not frappe.db.has_column("Company Print Options", "autofield"):
frappe.db.sql("""
ALTER TABLE `tabCompany Print Options`
ADD COLUMN `autofield` VARCHAR(255)
""")
# Check if the 'autofield_value' column exists and add it if it doesn't
if not frappe.db.has_column("Company Print Options", "autofield_value"):
frappe.db.sql("""
ALTER TABLE `tabCompany Print Options`
ADD COLUMN `autofield_value` VARCHAR(255)
""")
# Run the patch
if __name__ == "__main__":
execute()
Information about bug
Error when running migrate to run patches. Command ran
bench update --reset --no-backup && bench setup requirements && bench build
orbench --site est.localhost migrate
Version
erpnext 15.28.2 frappe 15.32.0 hrms 15.23.0 india_compliance 15.9.1
Relevant log output / Stack trace / Full Error Message.
Code of Conduct
Huly®: IC-2448