2016-01-13 215 views
0

創建新的Laravel 5.2.8項目。Laravel遷移錯誤

當我想要做的預定義的遷移,我得到一個錯誤:

[Illuminate\Database\QueryException] 
SQLSTATE[HY000]: General error: 1293 Incorrect table definition; there can be only one TIMESTAMP column with CURREN 
T_TIMESTAMP in DEFAULT or ON UPDATE clause (SQL: create table `users` (`id` int unsigned not null auto_increment pr 
imary key, `name` varchar(255) not null, `email` varchar(255) not null, `password` varchar(60) not null, `remember_ 
token` varchar(100) null, `created_at` timestamp default CURRENT_TIMESTAMP not null, `updated_at` timestamp default 
CURRENT_TIMESTAMP not null) default character set utf8 collate utf8_unicode_ci) 



[PDOException] 
SQLSTATE[HY000]: General error: 1293 Incorrect table definition; there can be only one TIMESTAMP column with CURREN 
T_TIMESTAMP in DEFAULT or ON UPDATE clause 

遷移:

Schema::create('users', function (Blueprint $table) { 
    $table->increments('id'); 
    $table->string('name'); 
    $table->string('email')->unique(); 
    $table->string('password', 60); 
    $table->rememberToken(); 
    $table->timestamps(); 
}); 

如何解決這個問題呢?

+0

@Maraboc,謝謝!我使用MySQL 5.5版本。更新後,我的問題解決了 –

回答

0

錯誤正是告訴你什麼是錯的。請參閱您的CREATE TABLE聲明;你不能有timestamp和默認的兩列CURRENT_TIMESTAMP

SQL:

create table `users` (`id` int unsigned not null auto_increment pr 
imary key, 
`name` varchar(255) not null, 
`email` varchar(255) not null, 
`password` varchar(60) not null, 
`remember_ 
token` varchar(100) null, 
`created_at` timestamp default CURRENT_TIMESTAMP not null, <-- here 
`updated_at` timestamp default CURRENT_TIMESTAMP not null) <-- here 
default character set utf8 collate utf8_unicode_ci;