Hi Jerry,
First, how old? Is it possible to upgrade from within the FreePBX application? Could you create a second box to do the upgrade on and simply move that back into production?
To answer your actual question:
The table asterisk.ivr_entries contains the “selection” column and the corresponding destination for a given IVR.
mysql -u user -ppassword -e “select * from asterisk.ivr_entries where selection = ‘8481234’;”
The table asterisk.trunks can be connected to the table asterisk.outbound_route_patterns by a join of each table to asterisk.outbound_route_trunks. Here’s a sample query; remove everything except * between “select” and from" so that it reads like the first query to see ALL the columns.
mysql -u user -ppassword -e "select \
asterisk.outbound_route_patterns.match_pattern_pass \
,asterisk.trunks.* \
from asterisk.outbound_route_patterns \
join asterisk.outbound_route_trunks \
on asterisk.outbound_route_patterns.route_id=asterisk.outbound_route_trunks.route_id \
join asterisk.trunks \
on asterisk.outbound_route_trunks.trunk_id=asterisk.trunks.trunkid \
where asterisk.outbound_route_patterns.match_pattern_pass = '_879XXX';"
You could probably join your destination from ivr_entries to something in trunks, but I’d have to put some test data into our server.
EDIT:
If your destination is a trunk, you could do this:
mysql -u user -ppassword -e "select * \
from asterisk.ivr_entries
join asterisk.trunks
on SUBSTRING(asterisk.ivr_entries.dest,LOCATE(',',asterisk.ivr_entries.dest)+1,1)=asterisk.trunks.trunkid;"
This works because the first number after the first comma in the dest column is the ID of the trunk:
select * from ivr_entries;
| ivr_id | selection | dest | ivr_ret |
| 1 | 1337 | ext-trunk,2,1 | 0 |
select * from trunks;
| trunkid | name | tech | outcid | keepcid | maxchans | failscript | dialoutprefix | channelid | usercontext | provider | disabled | continue |
| 1 | | dahdi | | | | | | g0 | | NULL | off | off |
| 2 | Bacon | pjsip | 7114222667 | off | | | | Bacon | | | on | off |
select * \
from asterisk.ivr_entries \
join asterisk.trunks \
on SUBSTRING(asterisk.ivr_entries.dest,LOCATE(',',asterisk.ivr_entries.dest)+1,1)=asterisk.trunks.trunkid;
| ivr_id | selection | dest | ivr_ret | trunkid | name | tech | outcid | keepcid | maxchans | failscript | dialoutprefix | channelid | usercontext | provider | disabled | continue |
| 1 | 1337 | ext-trunk,2,1 | 0 | 2 | Bacon | pjsip | 7114222667 | off | | | | Bacon | | | on | off |