Laravel 5 Migration,整数时的默认值无效


Laravel 5 Migration, Invalid default value when integer

我试图创建一个具有0作为其默认整数值的表代码如下所示:

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();
    });

但是当我运行迁移时,我得到了下一个错误:

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试图将字段estado设置为char值('0'),并作为自动递增的主键

任何帮助都将非常感谢

删除integer方法中的第二个参数。它将列设置为自动递增。查看Laravel API了解更多细节。

http://laravel.com/api/5.0/Illuminate/Database/Schema/Blueprint.html method_integer

$table->integer('estado')->default(0);