-- DB-02: GIN index on JSONB detailSnapshot for faster queries
-- This index enables efficient lookups on JSON fields within invoice snapshots
CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_invoices_detail_gin
  ON invoices USING GIN ("detailSnapshot");

-- Additional index for nomorFakturPajak (REG-01)
CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_invoices_faktur_pajak
  ON invoices (\"nomorFakturPajak\") WHERE \"nomorFakturPajak\" IS NOT NULL;

-- Additional index for konsolidasi PEB (REG-02)
CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_konsolidasi_peb
  ON konsolidasi_dokumen (\"nomorPEB\") WHERE \"nomorPEB\" IS NOT NULL;
