Laravel 迁移时外键不起作用

Laravel 迁移时外键不起作用,laravel,laravel-5,Laravel,Laravel 5,外键不工作 这是我的迁移文件 Schema::create('course_prospect', function (Blueprint $table) { $table->bigIncrements('id'); $table->integer('prospect_id')->length(11)->unsigned(); $table->foreign('prospect_id')->references('id')-

外键不工作

这是我的迁移文件

Schema::create('course_prospect', function (Blueprint $table) {
      $table->bigIncrements('id');

      $table->integer('prospect_id')->length(11)->unsigned();
      $table->foreign('prospect_id')->references('id')->on('prospect');

      $table->integer('course_id')->length(11)->unsigned();
      $table->foreign('course_id')->references('course_id')->on('course');

      $table->timestamps();
    });
我犯了这个错误

 Illuminate\Database\QueryException  : SQLSTATE[HY000]: General error: 
1005 Can't create table `customerinquirydb`.`#sql-104c_e9` (errno: 150 
"Foreign key constraint is incorrectly formed") (SQL: alter table 
`course_prospect` add constraint `course_prospect_prospect_id_foreign` 
foreign key (`prospect_id`) references `prospect` (`id`))

在Laravel中迁移具有外键的表时。必须首先创建外键所在的表(必须存在)!因此,请确保情况确实如此。

我认为这一行中可能重复的
id
应替换为
prospect\u id
$table->foreign('prospect\u id')->引用('id')->on('prospect')您是否也可以添加潜在客户和课程表?