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

后端 未结 22 906
有刺的猬
有刺的猬 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:48

    It is a simple question, so give a simple answer and stop beating about the bush, change your example $table->integer('user_id')->unsigned(); to $table->BigInteger('user_id')->unsigned(); to solve the foreign key error. so change integer to BigInteger in the migration file...

提交回复
热议问题