2015-05-19 137 views
6

我試圖創建具有作爲其默認的整數值 代碼看起來像一個表:Laravel 5遷移,無效的默認值時,整數

Schema::create('gsd_proyecto', function($table) { 
     $table->increments('id'); 
     $table->string('nombre', 80)->unique(); 
     $table->string('descripcion', 250)->nullable(); 
     $table->date('fechaInicio')->nullable(); 
     $table->date('fechaFin')->nullable(); 
     $table->integer('estado', 1)->default(0); 
     $table->string('ultimoModifico', 35)->nullable(); 
     $table->timestamps(); 
    }); 

但是當我運行遷移我m如果下一個錯誤:

Next exception 'Illuminate\Database\QueryException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1067 Invalid default value for 'estado' 

我檢查什麼是laravel創建的SQL,我發現旁邊

create table `gsd_proyecto` (
`id` int unsigned not null auto_increment primary key, 
`nombre` varchar(80) not null, 
`descripcion` varchar(250) null, 
`fechaInicio` date null, 
`fechaFin` date null, 
`estado` int not null default '0' auto_increment primary key, 
`ultimoModifico` varchar(35) null, 
`created_at` timestamp default 0 not null, 
`updated_at` timestamp default 0 not null 
) 

正如你所看到的,laravel正試圖設置字段埃斯塔與char值(「0」),也可以作爲一個自動增量主鍵

任何幫助將是非常讚賞

回答