[英]difference between timestamps and nullableTimestamps in Laravel 5.4 migration
According to Laravel documentation : 根据Laravel文档 :
$table->timestamps();
Adds nullable created_at
and updated_at
columns. created_at
和updated_at
列。 $table->nullableTimestamps();
Nullable versions of the timestamps()
columns. timestamps()
列的可空版本。 I don't understand. 我不明白 In other words, what I read is:
换句话说,我读到的是:
A
creates nullable columns A
创建可为空的列 B
is like A
but it creates nullable columns B
像A
一样A
但是它创建了可为空的列 What did I miss? 我错过了什么?
Since Laravel 5.2 there is no difference. 从Laravel 5.2开始,没有区别。 If you look at the source you'll see that
nullableTimestamps()
is an alias for timestamps()
如果您查看源代码 ,将会看到
nullableTimestamps()
是timestamps()
的别名。
/**
* Add nullable creation and update timestamps to the table.
*
* @return void
*/
public function timestamps()
{
$this->timestamp('created_at')->nullable();
$this->timestamp('updated_at')->nullable();
}
/**
* Add nullable creation and update timestamps to the table.
*
* Alias for self::timestamps().
*
* @return void
*/
public function nullableTimestamps()
{
$this->timestamps();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.