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

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

    Check the order of your migrations. If your migrate command is trying to make the sell_shipping_labels table before the orders table this will occur with MySQL. It seems to go on create migration date, oldest to newest. In other words, the order_id on the table it is trying to reference should exist.

    I have faced the same problem and I change create migration date.

提交回复
热议问题