How Can I Set the Default Value of a Timestamp Column to the Current Timestamp with Laravel Migrations?

前端 未结 9 1460
执笔经年
执笔经年 2020-11-27 10:21

I would like to make a timestamp column with a default value of CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP using the Laravel Schema Builder/Migrations. I hav

9条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-27 10:44

    If your're looking to set the current datetime for a dateTime column (like i was when I googled), use this way

    $table->dateTime('signed_when')->useCurrent();
    

提交回复
热议问题