-- v1.34 Performance + License Core base
START TRANSACTION;

ALTER TABLE party_ledger
  ADD INDEX idx_party_ledger_party_date_event (party_id, doc_date, event_at, id),
  ADD INDEX idx_party_ledger_doc_lookup (doc_type, doc_id);

ALTER TABLE sales_invoices
  ADD INDEX idx_si_status_date_party (status, invoice_date, party_id),
  ADD INDEX idx_si_date_id (invoice_date, id);

ALTER TABLE sales_items
  ADD INDEX idx_sales_items_invoice_item (invoice_id, item_id);

ALTER TABLE cashbox_transactions
  ADD INDEX idx_cbt_cashbox_date_id (cashbox_id, trx_date, id),
  ADD INDEX idx_cbt_ref (ref_type, ref_id);

ALTER TABLE checks
  ADD INDEX idx_checks_holder_status_due (current_holder_party_id, current_status, due_date);

ALTER TABLE stock_balances
  ADD INDEX idx_stock_balances_warehouse_item_qty (warehouse_id, item_id, qty);

COMMIT;
