CREATE INDEX IF NOT EXISTS queue_sessions_history_project_date_idx
    ON queue_sessions (project_id, business_date DESC, id);

CREATE INDEX IF NOT EXISTS queue_tickets_history_session_status_number_idx
    ON queue_tickets (queue_session_id, status, ticket_number);

CREATE INDEX IF NOT EXISTS queue_tickets_history_project_called_idx
    ON queue_tickets (project_id, called_at DESC);

CREATE INDEX IF NOT EXISTS call_batches_history_session_called_idx
    ON call_batches (queue_session_id, called_at DESC);

CREATE INDEX IF NOT EXISTS call_batch_tickets_history_batch_position_idx
    ON call_batch_tickets (call_batch_id, position);
