Skip to content

Commit

Permalink
Added support to new default constants for date/time fields;
Browse files Browse the repository at this point in the history
  • Loading branch information
edgardmessias committed Jul 14, 2015
1 parent a91571c commit e3666ea
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -345,8 +345,9 @@ protected function loadColumnSchema($column)

$c->defaultValue = null;
if ($defaultValue !== null) {
if ($c->type == self::TYPE_TIMESTAMP && trim($defaultValue) == 'CURRENT_TIMESTAMP') {
$c->defaultValue = new \yii\db\Expression('CURRENT_TIMESTAMP');
if (in_array($c->type, [self::TYPE_DATE, self::TYPE_DATETIME, self::TYPE_TIME, self::TYPE_TIMESTAMP])
&& preg_match('/(CURRENT_|NOW|NULL|TODAY|TOMORROW|YESTERDAY)/i', $defaultValue)) {
$c->defaultValue = new \yii\db\Expression(trim($defaultValue));
} else {
$c->defaultValue = $c->phpTypecast($defaultValue);
}
Expand Down

0 comments on commit e3666ea

Please sign in to comment.