Version doc cleanup

Hi,

How I can make version doc cleanup? Version table is around 800k+ entires.
I tried this

frappe.db.delete(“Version”, {
“ref_doctype”: “***”,
“modified”: (“<”, frappe.utils.add_to_date(frappe.utils.now(), days=(keepForDays * -1)))
})

frappe.db.sql(“”"
DELETE FROM tabVersion
WHERE ref_doctype = %s
AND modified < %s
“”“, (”***", frappe.utils.add_to_date(frappe.utils.now(), days=(keepForDays * -1))))

For first code I got missing delete method. For second read-only queries.
Is there any way to delete docs from server script?

Hi @Pararera

I assume you are on Frappe cloud with no access to bench?

As a last resort you can go into the DocType and then do a bulk delete 2,500 at a time (320 times for 800,000 records)

Maybe ask cloud support to help you out. Best of luck