-- Suggested indexes for a relational DB migration (PostgreSQL/MySQL style)
-- Apply only when data is moved from JSON files to SQL tables.

-- Sales invoices
CREATE INDEX IF NOT EXISTS idx_sales_invoices_invoice_number ON sales_invoices (invoice_number);
CREATE INDEX IF NOT EXISTS idx_sales_invoices_date ON sales_invoices (invoice_date DESC);
CREATE INDEX IF NOT EXISTS idx_sales_invoices_customer_name ON sales_invoices (customer_name);

-- Purchase orders
CREATE INDEX IF NOT EXISTS idx_purchase_orders_order_number ON purchase_orders (order_number);
CREATE INDEX IF NOT EXISTS idx_purchase_orders_date ON purchase_orders (order_date DESC);
CREATE INDEX IF NOT EXISTS idx_purchase_orders_supplier_name ON purchase_orders (supplier_name);

-- Parties
CREATE INDEX IF NOT EXISTS idx_customers_name ON customers (name);
CREATE INDEX IF NOT EXISTS idx_suppliers_name ON suppliers (name);

-- Composite examples for common filtered listings
CREATE INDEX IF NOT EXISTS idx_sales_invoices_date_status ON sales_invoices (invoice_date DESC, status);
CREATE INDEX IF NOT EXISTS idx_purchase_orders_date_status ON purchase_orders (order_date DESC, status);
