运行migrate命令时,显示以下错误
[Illuminate\Database\QueryException]
SQLSTATE[HY000]: General error: 1005 Can't create table 'SSA_DATA.#sql-431_1b8' (errno: 150) (SQL: alter table `reports_fields` add constraint rep
orts_fields_report_id_foreign foreign key (`report_id`) references `reports_list` (`id`))
迁移代码低于
public function up()
{
Schema::create('reports_fields', function(Blueprint $table)
{
$table->increments('id');
$table->smallInteger('report_id')->unsigned();
$table->smallInteger('field_id')->unsigned();
});
Schema::table('reports_fields', function($table)
{
$table->foreign('report_id')->references('id')->on('reports_list');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('reports_fields');
}
这是什么原因?