Transfer calls based on CID

As mentioned before, you could manage and update this entirely from the GUI, even in bulk with the import export functions.

If you are looking to do something more on the DB backend, then review these posts. They will give you everything you are looking for (asterisk phonebook, inbound route table and how to enable superfecta in bulk).

If you are adding things directly to the tables, be careful with the inputs (the risk of breaking something increases without the safeguards of the GUI), and don’t forget to reload FreePBX for the updates to take effect (adding data to the tables without reloading will not work).

Good luck, and please share your approach and results. It will no doubt help others looking to do this in the future.