fix: patch for migrating default sort order

This commit is contained in:
Ankush Menat 2024-03-23 16:51:21 +05:30
parent 3896296c6f
commit 0212d9362d
2 changed files with 26 additions and 0 deletions

View file

@ -236,3 +236,4 @@ frappe.patches.v15_0.sanitize_workspace_titles
frappe.patches.v15_0.migrate_role_profile_to_table_multi_select
frappe.patches.v15_0.migrate_session_data
frappe.custom.doctype.property_setter.patches.remove_invalid_fetch_from_expressions
frappe.patches.v16_0.switch_default_sort_order

View file

@ -0,0 +1,25 @@
import click
import frappe
from frappe.patches.v14_0.drop_unused_indexes import drop_index_if_exists
def execute():
if frappe.db.db_type == "postgres":
return
db_tables = frappe.db.get_tables(cached=False)
doctypes = frappe.get_all(
"DocType",
{"is_virtual": 0, "istable": 0},
pluck="name",
)
for doctype in doctypes:
table = f"tab{doctype}"
if table not in db_tables:
continue
frappe.db.add_index(doctype, ["creation"], index_name="creation")
click.echo(f"✓ created creation index from {table}")
drop_index_if_exists(table, "modified")