From 9a39ebe66f11a5a0c8158d83bc37dec207b9cb8c Mon Sep 17 00:00:00 2001 From: Diogo Cordeiro Date: Sat, 25 Aug 2018 02:20:10 +0100 Subject: [PATCH] Database fields with timestamp type now allow CURRENT_TIMESTAMP to be set as default value Add default values to created and modified columns of Profile_list table to fix issue #338 --- classes/Profile_list.php | 4 ++-- lib/schema.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/classes/Profile_list.php b/classes/Profile_list.php index b60f4afffd..e1e02da23c 100644 --- a/classes/Profile_list.php +++ b/classes/Profile_list.php @@ -48,8 +48,8 @@ class Profile_list extends Managed_DataObject 'description' => array('type' => 'text', 'description' => 'description of the people tag'), 'private' => array('type' => 'int', 'size' => 'tiny', 'default' => 0, 'description' => 'is this tag private'), - 'created' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date the tag was added'), - 'modified' => array('type' => 'timestamp', 'not null' => true, 'description' => 'date the tag was modified'), + 'created' => array('type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date the tag was added'), + 'modified' => array('type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date the tag was modified'), 'uri' => array('type' => 'varchar', 'length' => 191, 'description' => 'universal identifier'), 'mainpage' => array('type' => 'varchar', 'length' => 191, 'description' => 'page to link to'), diff --git a/lib/schema.php b/lib/schema.php index f536f01645..17d4192ed4 100644 --- a/lib/schema.php +++ b/lib/schema.php @@ -790,7 +790,7 @@ class Schema function quoteDefaultValue($cd) { - if ($cd['type'] == 'datetime' && $cd['default'] == 'CURRENT_TIMESTAMP') { + if (($cd['type'] == 'datetime' || $cd['type'] == 'timestamp') && $cd['default'] == 'CURRENT_TIMESTAMP') { return $cd['default']; } else { return $this->quoteValue($cd['default']);