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

后端 未结 22 875
有刺的猬
有刺的猬 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条回答
  •  自闭症患者
    2020-11-30 07:41

    You should first create Categories and users Table when create "meals"

    To solve the issue you should rename migration files of Category and Users to date of before Meals Migration file that create those before Meals table.


    sample:

    2019_04_10_050958_create_users_table 
    2019_04_10_051958_create_categories_table
    2019_04_10_052958_create_meals_table
    

提交回复
热议问题