blob: fc17b1dcbda37ea4666a2133af99713a714a6bff [file] [log] [blame]
Ankush Menat78733382023-12-21 20:09:10 +05301import frappe
2from frappe.tests.utils import FrappeTestCase
3
4INDEXED_FIELDS = {
5 "Bin": ["item_code"],
6 "GL Entry": ["voucher_type", "against_voucher_type"],
7 "Purchase Order Item": ["item_code"],
8 "Stock Ledger Entry": ["warehouse"],
9}
10
11
12class TestPerformance(FrappeTestCase):
13 def test_ensure_indexes(self):
14 # These fields are not explicitly indexed BUT they are prefix in some
15 # other composite index. If those are removed this test should be
16 # updated accordingly.
17 for doctype, fields in INDEXED_FIELDS.items():
18 for field in fields:
19 self.assertTrue(
20 frappe.db.sql(
21 f"""SHOW INDEX FROM `tab{doctype}`
22 WHERE Column_name = "{field}" AND Seq_in_index = 1"""
23 )
24 )