diff --git a/.github/workflows/_base-server-tests.yml b/.github/workflows/_base-server-tests.yml index 92b55b6248..aa47c70ef1 100644 --- a/.github/workflows/_base-server-tests.yml +++ b/.github/workflows/_base-server-tests.yml @@ -85,7 +85,7 @@ jobs: env: POSTGRES_PASSWORD: ${{ env.DB_ROOT_PASSWORD }} smtp_server: - image: rnwood/smtp4dev + image: rnwood/smtp4dev:3.7.1 ports: - 2525:25 - 3000:80 diff --git a/frappe/core/doctype/doctype/doctype.js b/frappe/core/doctype/doctype/doctype.js index b91db43c54..62b9932355 100644 --- a/frappe/core/doctype/doctype/doctype.js +++ b/frappe/core/doctype/doctype/doctype.js @@ -32,12 +32,6 @@ frappe.ui.form.on("DocType", { }, refresh: function (frm) { - if (frm.doc.custom === 1) { - frm.add_custom_button(__("Trim Table"), function () { - frm.trigger("trim_table"); - }); - } - frm.set_query("role", "permissions", function (doc) { if (doc.custom && frappe.session.user != "Administrator") { return { diff --git a/frappe/core/doctype/doctype/doctype.py b/frappe/core/doctype/doctype/doctype.py index 260e1494b4..0860e80297 100644 --- a/frappe/core/doctype/doctype/doctype.py +++ b/frappe/core/doctype/doctype/doctype.py @@ -1058,17 +1058,6 @@ class DocType(Document): ) return True - @frappe.whitelist() - def trim_table(self): - from frappe.model.meta import trim_table - - """Removes database fields that don't exist in the doctype. - - This may be needed as maintenance since removing a field in a DocType - doesn't automatically delete the db field. - """ - trim_table(self.name, dry_run=False) - def validate_series(dt, autoname=None, name=None): """Validate if `autoname` property is correctly set.""" diff --git a/frappe/custom/doctype/customize_form/customize_form.js b/frappe/custom/doctype/customize_form/customize_form.js index 44fe8e249c..2d047d4c30 100644 --- a/frappe/custom/doctype/customize_form/customize_form.js +++ b/frappe/custom/doctype/customize_form/customize_form.js @@ -202,6 +202,40 @@ frappe.ui.form.on("Customize Form", { ); }, + async trim_table(frm) { + let dropped_columns = await frappe.xcall( + "frappe.custom.doctype.customize_form.customize_form.get_orphaned_columns", + { doctype: frm.doc.doc_type } + ); + + if (!dropped_columns?.length) { + frappe.toast(__("This doctype has no orphan fields to trim")); + return; + } + let msg = __( + "Warning: DATA LOSS IMMINENT! Proceeding will permanently delete following database columns from doctype {0}:", + [frm.doc.doc_type.bold()] + ); + msg += "