PJSIP Defaults For Endpoints When Using Realtime

Home » Asterisk Users » PJSIP Defaults For Endpoints When Using Realtime
Asterisk Users 4 Comments

Until Asterisk 11 I could use sip.conf to set defaults for all phones (language, dtmf, vmexten, etc) and just leave many fields in the database as NULL. What would be the proper way to do this for Asterisk
13 and PJSIP?


Telecomunicaciones Abiertas de México S.A. de C.V. Carlos Chávez
+52 (55)9116-91161

4 thoughts on - PJSIP Defaults For Endpoints When Using Realtime

  • Carlos Chavez wrote:

    Kia ora,

    PJSIP doesn’t have the ability in it to override built-in defaults for everything. You have to specify it yourself for realtime. If using config files then config file templates can be used to do this.

    Cheers,

  • If the database you are using is MariaDB or MySQL, then you should be able to set default values for columns in the table definition. Then when you do an INSERT into only some columns, the rest will be populated with the default values.

    To alter the structure of an already-created table, use something like

    ALTER TABLE stuff CHANGE COLUMN foo foo VARCHAR(20) NOT NULL DEFAULT “wibble”;

    (Yes, the column name should be there twice: you might want to rename it, so you have to specify an old and a new name even if the two are the same.)

    You will then need to use something like

    UPDATE stuff SET foo=”wibble” WHERE foo IS NULL;

  • While this will work, your defaults may not survive the next time alembic is run to upgrade the database. It’s rare but we do occasionally drop and re-create columns to change their types.

    You could also play with insert triggers which are attached to the table instead of specific columns. These might be easier to manage.