lumenvue
lumenvue copied to clipboard
php artisan migrate can not success
php artisan migrate can not success!
this is the error message: $ php artisan migrate
[Illuminate\Database\QueryException]
SQLSTATE[42000]: Syntax error or access violation: 1067 Invalid default value for 'created_at' (SQL: create table users (id int unsigned not null auto_increment primary key, name
varchar(255) not null, email varchar(255) not null, password varchar(60) not null, admin tinyint(1) not null default '0', remember_token varchar(100) null, created_at timestam
p default 0 not null, updated_at timestamp default 0 not null) default character set utf8 collate utf8_unicode_ci)
[PDOException] SQLSTATE[42000]: Syntax error or access violation: 1067 Invalid default value for 'created_at'
Hello It's an issue with your database.
You can change the $table->timestamps() fields for $table->nullableTimestamps() in migrations.
You can also change this in config:
'mysql' => [
'driver' => 'mysql',
...
'strict' => true, // change false to true
],
Or change your database version ^^
Thanks!
this also can be solve by replacing $table->timestamps(); by
$table->timestamp('created_at')->default(\DB::raw('CURRENT_TIMESTAMP'));
$table->timestamp('updated_at')->default(\DB::raw('CURRENT_TIMESTAMP'));