php-artisan迁移外键错误


php artisan migrate foreign key error

主表POll

 public function up()
    {
        Schema::create('poll', function (Blueprint $table) {
            $table->increments('id');
            $table->timestamps();
            $table->string('poll_question', 255);
            $table->boolean('status',1)->default(0)->index();
            $table->unsignedInteger('order');
        });
    }

详细信息表

  public function up()
    {
        Schema::create('poll_option', function (Blueprint $table) {
            $table->increments('id');
            $table->timestamps();
            $table->integer('poll_id');
            $table->string('poll_option', 255);
            $table->unsignedInteger('vote_poll_option');
            $table->unsignedInteger('order');
            $table->boolean('status',1)->default(0)->index();
            $table->foreign('poll_id')->references('id')->on('poll')->onUpdate('cascade')->onDelete('cascade');
        });
    }

当我用外键运行php-artisan时

SQLSTATE[HY000]:一般错误:1005无法创建表mydb#sql-6f4_433(错误号:150"外键约束格式不正确")

注意:我使用的是laravel 5.2和mysql类型已经是Innodb。错误形成

的主要原因是什么

在详细信息表中

public function up()
    {
        Schema::create('poll_option', function (Blueprint $table) {
            $table->increments('id');
            $table->timestamps();
            $table->integer('poll_id')->unsigned(); //Change Here
            $table->string('poll_option', 255);
            $table->unsignedInteger('vote_poll_option');
            $table->unsignedInteger('order');
            $table->boolean('status',1)->default(0)->index();
            $table->foreign('poll_id')
              ->references('id')->on('poll')
              ->onDelete('CASCADE')
              ->onUpdate('CASCADE');
        });
    }

这将适用于