参考: ​​https://stackoverflow.com/questions/18962757/when-is-a-timestamp-auto-updated​

核心:

DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP

[MySQL]如何自动更新timestap_laravel

 

[MySQL]如何自动更新timestap_laravel migrate_02

结合laravel  migrate:

$table->timestamp('created_at')->useCurrent();
$table->timestamp('updated_at')->default(DB::raw('CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP'));