I have a migration that has the timestamps()
method, and then I have a seed to seed this table.
Schema::create('mytable', function (Blueprint $table) {
$table->increments('id');
$table->string('title');
$table->timestamps();
});
The seed looks like this:
DB::table('mytable')->insert([
[
'title' => 'My Awesome Title'
]
]);
当它全部运行时,请使用:
php artisan migrate:refresh --seed
该项被插入,但created_at
和updated_at
的值都是0000-00-00 00:00:00
为什么设置不正确?
以下是它创建的柱方案:
`created_at` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00',
`updated_at` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00',
I would like these schemes:
`created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
`updated_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,