Ankush Menat | 7873338 | 2023-12-21 20:09:10 +0530 | [diff] [blame] | 1 | import frappe |
| 2 | from frappe.tests.utils import FrappeTestCase |
| 3 | |
| 4 | INDEXED_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 | |
| 12 | class 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 | ) |