Why is creating Foreign Key in Laravel 5.8 failing?

后端 未结 2 723
情话喂你
情话喂你 2021-01-17 17:55

The migration script below was running smoothly in an older version of Laravel but I added it to my fresh Laravel 5.8 and ran the script. I\'m getting Error: foreign k

2条回答
  •  抹茶落季
    2021-01-17 18:29

      update your `integer('user_id')` to `bigInteger('user_id')`
    public function up() { 
            Schema::create('evaluation', function (Blueprint $table) { 
                $table->increments('id'); 
                $table->bigInteger('user_id')->unsigned()->index(); 
                $table->timestamps();
                $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
            });
        }
    

提交回复
热议问题