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”),也可以作为一个自动增量主键
任何帮助将是非常赞赏
它的工作!非常感谢!我在像MySql这样的定义思考....现在我正在使用tinyInteger,它现在正在工作。非常感谢! – WindSaber