Laravel 5 外键拉威尔错误

Laravel 5 外键拉威尔错误,laravel-5,Laravel 5,当我试图设置两个表之间的关系时,我收到错误: D:\wamp\www>php artisan迁移迁移表已成功创建 [Illumb\Database\QueryException]SQLSTATE[HY000]:常规 错误:1215无法添加外键约束SQL:alter table 里滕注册公司 rittenregistratie_karakterritid_外键karakterritid 在d元素级联上引用karakterrit id [PDOException]SQLSTATE[HY000]:一般

当我试图设置两个表之间的关系时,我收到错误:

D:\wamp\www>php artisan迁移迁移表已成功创建

[Illumb\Database\QueryException]SQLSTATE[HY000]:常规 错误:1215无法添加外键约束SQL:alter table 里滕注册公司 rittenregistratie_karakterritid_外键karakterritid 在d元素级联上引用karakterrit id

[PDOException]SQLSTATE[HY000]:一般错误:1215无法添加 外键约束

D:\wamp\www>

这是我的移民登记表,是荷兰语:

    <?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateRittenregistratieTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('rittenregistratie', function (Blueprint $table) 
        {
            $table->increments('id');
            $table->integer('user_id')->unsigned();
            $table->timestamps('datum');
            $table->integer('beginstand');
            $table->integer('eindstand');
            $table->text('van');
            $table->text('naar');
            $table->text('bezoekadres');
            $table->text('geredenroute');
            $table->integer('karakterritid')->default(1);
            $table->text('toelichting');
            $table->integer('kilometerszakelijk');
            $table->integer('kilomteresprive');

            $table->foreign('user_id')
                        ->references('id')
                        ->on('users')
                        ->onDelete('cascade');

            $table->foreign('karakterritid')
                        ->references('id')
                        ->on('karakterrit')
                        ->onDelete('cascade');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::drop('rittenregistratie');
    }
}
这就是我想涉及的内容:

<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateKarakterritTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('karakterrit',function(Blueprint $table)
        {
            $table->increments('id');
            $table->text('rit');          
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::drop('karakterrit');
    }
}

我做错了什么?

您能确认CreateKarakTerritable迁移的位置吗?我的意思是在CreateRittenRegistrateTable迁移之前进行迁移?如何更改迁移顺序?重新创建迁移!但这次先创建了Karakterrittable。我再次创建了它们,但仍然收到错误:[Illumb\Database\QueryException]SQLSTATE[HY000]:常规错误:1215无法添加外键约束SQL:alter表rittenregistratie添加约束rittenregistratie\u karakterri tid\u外键karakterritid在删除时引用了karakterrit id,并且我已首先创建了karakterrit?