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

后端 未结 18 2525
谎友^
谎友^ 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:07

    Most times the reason for this error is usually due to the order of which the migration files are listed or error due to type casting.

    Always make sure that the migration of the file which the foreign constraints is to be imposed on comes after the parent migration. And for the latter, make sure its an unsignedBigInteger , although former version of laravel (<5.4) could ignore this type casting error.

提交回复
热议问题