这是我的迁移架构:
public function up()
{
Schema::create('objects', function (Blueprint $table) {
$table->increments('id');
$table->timestamp('timestamp1');
$table->timestamp('timestamp2');
});
}
但是当我执行时php artisan migrate
,我得到了这个错误:
Illuminate\Database\QueryException:SQLSTATE[42000]:语法错误或访问冲突:1067 'timestamp2' 的默认值无效(SQL:创建表
objects
(id
int unsigned not null auto_increment 主键,timestamp1
timestamp not null,timestamp2
timestamp not null)默认字符集utf8mb4 整理 utf8mb4_unicode_ci)
我必须指出,当我删除$table->timestamp(...);
两条线中的一条时,它可以工作,但是当两者都存在时它不会。Object.php
模型是空的。我犯错了吗?
我已经阅读了这篇文章,但是即使我更改为时不再有错误timestamp(...)
,dateTime(...)
我只想要时间戳。