I have an extension stuck in the DB. It’s not in the gui, but when I try to add extension 138 for example, it says it’s in use. I ran the following and still have the same result
USE asterisk;
DELETE FROM sip WHERE id = ‘xxx’;
DELETE FROM users WHERE extension = ‘xxx’;
DELETE FROM devices WHERE id = ‘xxx’;
Not sure which version of FreePBX you use, but if you hover over that icon, it should tell you where it’s in use.
Might be it’s a Queue, Ring Group or Custom Extension.
Have you done SELECT * FROM sip WHERE id='138' and see how many, if any, results are returned?
You could also do: SELECT DISTINCT id FROM sip and that will kick back all the unique ids, which in this the case of this table is the extension number.