lumenvue icon indicating copy to clipboard operation
lumenvue copied to clipboard

php artisan migrate can not success

Open CloudS-Hu opened this issue 8 years ago • 3 comments
trafficstars

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'

CloudS-Hu avatar Apr 08 '17 01:04 CloudS-Hu

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 ^^

bestmomo avatar Apr 08 '17 15:04 bestmomo

Thanks!

CloudS-Hu avatar Apr 10 '17 06:04 CloudS-Hu

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'));

rcdosado avatar Dec 22 '17 12:12 rcdosado