<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jul 14, 2016 at 6:45 AM, A J Stiles <span dir="ltr"><<a href="mailto:asterisk_list@earthshod.co.uk" target="_blank">asterisk_list@earthshod.co.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On Thursday 14 Jul 2016, Joshua Colp wrote:<br>
> Carlos Chavez wrote:<br>
> > Until Asterisk 11 I could use sip.conf to set defaults for all phones<br>
> > (language, dtmf, vmexten, etc) and just leave many fields in the<br>
> > database as NULL. What would be the proper way to do this for Asterisk<br>
> > 13 and PJSIP?<br>
><br>
> Kia ora,<br>
><br>
> PJSIP doesn't have the ability in it to override built-in defaults for<br>
> everything. You have to specify it yourself for realtime. If using<br>
> config files then config file templates can be used to do this.<br>
<br>
</span>If the database you are using is MariaDB or MySQL, then you should be able to<br>
set default values for columns in the table definition.  Then when you do an<br>
INSERT into only some columns, the rest will be populated with the default<br>
values.<br>
<br>
To alter the structure of an already-created table, use something like<br>
<br>
ALTER TABLE stuff CHANGE COLUMN foo foo VARCHAR(20) NOT NULL DEFAULT "wibble";<br>
<br>
(Yes, the column name should be there twice: you might want to rename it, so<br>
you have to specify an old and a new name even if the two are the same.)<br>
<br>
You will then need to use something like<br>
<br>
UPDATE stuff SET foo="wibble" WHERE foo IS NULL;<br></blockquote><div><br></div><div>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.</div><div><br></div><div>You could also play with insert triggers which are attached to the table instead of specific columns.  These might be easier to manage.<br></div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<span class="HOEnZb"><font color="#888888"><br>
--<br>
AJS<br>
<br>
Note:  Originating address only accepts e-mail from list!  If replying off-<br>
list, change address to asterisk1list at earthshod dot co dot uk .<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
--<br>
_____________________________________________________________________<br>
-- Bandwidth and Colocation Provided by <a href="http://www.api-digital.com" rel="noreferrer" target="_blank">http://www.api-digital.com</a> --<br>
New to Asterisk? Join us for a live introductory webinar every Thurs:<br>
               <a href="http://www.asterisk.org/hello" rel="noreferrer" target="_blank">http://www.asterisk.org/hello</a><br>
<br>
asterisk-users mailing list<br>
To UNSUBSCRIBE or update options visit:<br>
   <a href="http://lists.digium.com/mailman/listinfo/asterisk-users" rel="noreferrer" target="_blank">http://lists.digium.com/mailman/listinfo/asterisk-users</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><span style="font-size:12.8px">George Joseph</span><br style="font-size:12.8px"><span style="font-size:12.8px">Digium, Inc. | Software Developer</span><span style="font-size:12.8px"><br>445 Jan Davis Drive NW - Huntsville, AL 35806 - US<br></span><span style="font-size:12.8px">Check us out at: </span><a href="http://www.digium.com/" rel="noreferrer" style="color:rgb(17,85,204);font-size:12.8px" target="_blank">www.digium.com</a><span style="font-size:12.8px"> & </span><a href="http://www.asterisk.org/" rel="noreferrer" style="color:rgb(17,85,204);font-size:12.8px" target="_blank">www.asterisk.org</a><br><div><br></div></div></div>
</div></div>