this my code schema goimon
public function up()
{
Schema::create('goimon', function (Blueprint $table) {
$table->engine = 'InnoDB';
$table->charset = 'utf8';
$table->collation = 'utf8_unicode_ci';
$table->increments('MaGoiMon');
$table->string('TinhTrang');
//$table->unsignedInteger('MaNhanVien');
$table->integer('MaNhanVien')->unsigned();
$table->unsignedInteger('MaBan');
$table->foreign('MaBan')->references('MaBan')->on('banan');
$table->foreign('MaNhanVien')->references('MaNhanVien')->on('nhanvien');
$table->timestamps();
});
}
and second schema :
public function up()
{
Schema::create('nhanvien', function (Blueprint $table) {
$table->engine = 'InnoDB';
$table->increments('MaNhanVien');
$table->string('TenNhanVien');
$table->string('TenDangNhap');
$table->string('MatKhau');
$table->boolean('GioiTinh');
$table->date('NgaySinh');
$table->integer('CMND');
$table->integer('quyen');
$table->timestamps();
});
}
and my error
Illuminate\Database\QueryException : SQLSTATE[HY000]: General error: 1005 Can't create table qlnhahang.#sql-12bc_ 491 (errno: 150 "Foreign key constraint is incorrectly formed") (SQL: alter table goimon add constraint goimon_manha nvien_foreign foreign key (MaNhanVien) references nhanvien (MaNhanVien))
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire