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

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

    1. Migration files should be created in such a way that the parent migration should come first and the migration file with the foreign key next.
    2. The foreign key and the primary id in the other table should have exactly similar property. If the primary id is increments then make the foreign key integer('xxx_id')->unsigned();

提交回复
热议问题