Reputation: 1276
I am trying to run a migration that works perfectly fine on Laravel 5.2 version, but when I try to run it on the laravel 5.5 I get an error:
In Connection.php line 664:
SQLSTATE[42000]: Syntax error or access violation: 1067 Invalid default value for 'to_date' (SQL: create table
transactions
(id
int unsigned not null auto_increment primary key,user_id
int unsigned not null,vehicle_id
int unsigned not null,from_date
t
imestamp not null,to_date
timestamp not null,flight_number
varchar(255) not null,created_at
timestamp null,updated_at
ti
mestamp null) default character set utf8mb4 collate utf8mb4_unicode_ci)In Connection.php line 458: SQLSTATE[42000]: Syntax error or access violation: 1067 Invalid default value for 'to_date'
This it the migration for that table:
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateTransactionsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('transactions', function (Blueprint $table) {
$table->increments('id');
$table->integer('user_id')->unsigned();
$table->foreign('user_id')->references('id')->on('users');
$table->integer('vehicle_id')->unsigned();
$table->foreign('vehicle_id')->references('id')->on('vehicles');
$table->timestamp('from_date');
$table->timestamp('to_date');
$table->string('flight_number');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('transactions');
}
}
Why is it not working with the new version of laravel when it is working with the 5.2?
Upvotes: 0
Views: 1568
Reputation: 1276
I found what was causing the problem, in laravel 5.5 MySQL strict mode is enabled in laravel config database.php
file by default, by setting the mode to 'strict' => false
, like in the version 5.3 I am able to run the migration.
Upvotes: 2