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

后端 未结 22 876
有刺的猬
有刺的猬 2020-11-30 07:21

When migrating my DB, this error appears. Below is my code followed by the error that I am getting when trying to run the migration.

Code



        
22条回答
  •  -上瘾入骨i
    2020-11-30 07:45

    @JuanBonnett’s question has inspired me to find the answer. I used Laravel to automate the process without considering the creation time of the file itself. According to the workflow, “meals” will be created before the other table (categories) because I created its schema file (meals) before categories. That was my fault.

提交回复
热议问题