Here's my migration schema:
public function up()
{
Schema::create('objects', function (Blueprint $table) {
$table->increments('id');
$table->timestamp('timestamp1');
$table->timestamp('timestamp2');
});
}
But when I execute php artisan migrate
, I get this error:
Illuminate\Database\QueryException : SQLSTATE[42000]: Syntax error or access violation: 1067 Invalid default value for 'timestamp2' (SQL: create table
objects
(id
int unsigned not null auto_increment primary key,timestamp1
timestamp not null,timestamp2
timestamp not null) default character set utf8mb4 collate utf8mb4_unicode_ci)
I must indicate that when I remove one of the 2 $table->timestamp(...);
lines it works, but it doesn't when there is both. And the Object.php
model is empty as it can be. Did I make a mistake?
I have read this post, but even though there is no longer errors when I change timestamp(...)
into dateTime(...)
, I only want timestamps.