feat: allow re-running patches in developer mode

Simpler debugging.
This commit is contained in:
Ankush Menat 2023-05-31 16:38:51 +05:30
parent 4104e7d733
commit 3bbe4498a0
2 changed files with 14 additions and 1 deletions

View file

@ -4,5 +4,9 @@
frappe.ui.form.on("Patch Log", {
refresh: function (frm) {
frm.disable_save();
frm.add_custom_button(__("Re-Run Patch"), () => {
frm.call("rerun_patch");
});
},
});

View file

@ -4,11 +4,20 @@
# License: MIT. See LICENSE
import frappe
from frappe import _
from frappe.model.document import Document
class PatchLog(Document):
pass
@frappe.whitelist()
def rerun_patch(self):
from frappe.modules.patch_handler import run_single
if not frappe.conf.developer_mode:
frappe.throw(_("Re-running patch is only allowed in developer mode."))
run_single(self.patch, force=True)
frappe.msgprint(_("Successfully re-ran patch: {0}").format(self.patch), alert=True)
def before_migrate():