Laravel migration (errno: 150 “Foreign key constraint is incorrectly formed”)

后端 未结 18 2482
谎友^
谎友^ 2020-12-05 14:15

I have an orders table and a have a sell_shipping_labels which references orders.id as a foreign. However when I run the Laravel migration I get th

18条回答
  •  天命终不由人
    2020-12-05 15:10

    the foreign key must be an "unsignedBigInteger" and it will be fixed, something like this:

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

提交回复
热议问题