If I run this in a migration script, there are no issues:
Schema::create('cancel_requests', function (Blueprint $table) {
$table->id();
$table->timestamp('date')->index();
});
But the moment I add another timestamp:
Schema::create('cancel_requests', function (Blueprint $table) {
$table->id();
$table->timestamp('date')->index();
$table->timestamp('created_at')->index();
});
Now I get this error:
QLSTATE[42000]: Syntax error or access violation: 1067 Invalid default value for 'created_at'
I can see the sql being generated as:
create table `cancel_requests`
(
`id` bigint unsigned not null auto_increment primary key,
`date` timestamp not null,
`created_at` timestamp not null
) default character set utf8mb4 collate 'utf8mb4_unicode_ci'
Can someone please explain to me why this is failing when the "date" field has no issue and the sql being generated does not look incorrect?