Skip to content

Commit e3666ea

Browse files
committed
Added support to new default constants for date/time fields;
1 parent a91571c commit e3666ea

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Schema.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -345,8 +345,9 @@ protected function loadColumnSchema($column)
345345

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

0 commit comments

Comments
 (0)