# Copyright (c) 2020, Xhive LLC
# MIT License. See license.txt


import xhiveframework


def execute():
	xhiveframework.reload_doc("setup", "doctype", "employee")

	if xhiveframework.db.has_column("Employee", "reason_for_resignation"):
		xhiveframework.db.sql(
			""" UPDATE `tabEmployee`
            SET reason_for_leaving = reason_for_resignation
            WHERE status = 'Left' and reason_for_leaving is null and reason_for_resignation is not null
        """
		)
