How can I add a default to a field that is a timestamp, so that if updates to the record don't include the column, it is automatically populated by the database engine? In mysql, the create for the column would be:
`time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'event timestamp'
In the install.xml file, timestamp isn't an allowed type so it uses datetime.
<FIELD NAME="time" TYPE="datetime" NOTNULL="true" DEFAULT="CURRENT_TIMESTAMP" SEQUENCE="false"/>
XMLDB editor warns about this if the type is set to timestamp, even though lib/xmldb/xmldb_field.php seems to show knowledge of the XMLDB_TYPE_TIMESTAMP field type.
I used xmldb editor to generate the php. This generates the column as type "datetime", with the default set at "current_timestamp". Obviously it's getting this from the install.xml file.
$table->add_field('time', XMLDB_TYPE_DATETIME, null, null, XMLDB_NOTNULL, null, 'CURRENT_TIMESTAMP');
When upgrade.php is executed, it throws an error:
Debug info: Invalid default value for 'time'
time DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
I'm having to create it without a default, then go in and alter the table by hand. Surely there's an official way?