运行迁移命令时出错

时间:2015-01-03 16:05:11

标签: php laravel migration

运行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');
 }

这是什么原因?

0 个答案:

没有答案