以下是我尝试按所述顺序运行的两个迁移。varitypes是相同的,我在制作表格后添加了FK,但它仍然给我带来了1215 Cannot add foreign key constraint错误。
一般错误 1215:无法为 Laravel 5 添加外键约束
2019_12_10_130856_all_skillset.php
public function up(){
Schema::create('all_skillsets', function(Blueprint $table){
$table->increments('id');
$table->char('skillset');
});
}
2019_12_10_300000_skillset.php
public function up(){
Schema::create('skillsets', function(Blueprint $table){
$table->increments('id');
$table->unsignedInteger('spid');
$table->char('skill');
});
Schema::table('skillsets', function(Blueprint $table){
$table->foreign('skill')->references('skillset')->on('all_skillsets');
$table->foreign('spid')->references('id')->on('players');
});
}
慕丝7291255