Ich habe versucht, eine Tabelle zu erstellen als Standard-Integer-Wert mit Der Code wie folgt aussieht:Laravel 5 Migration, Invalid Standardwert, wenn integer
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();
});
Aber wenn ich die Migration laufen I‘ m immer den nächsten Fehler:
Next exception 'Illuminate\Database\QueryException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1067 Invalid default value for 'estado'
ich war die Überprüfung, was die SQL von Laravel erstellt ist und ich fand nächste
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
)
Wie Sie sehen können, Laravel versucht, das Feld estado mit einem char-Wert (‚0‘) und auch als eine Autoincrement Primärschlüssel
Jede Hilfe wirklich
geschätzt werden
Es hat funktioniert! Danke vielmals! Ich habe in einer Definition wie MySql ... gedacht. Stattdessen benutze ich jetzt tinyInteger und es funktioniert jetzt. Danke vielmals! – WindSaber