How to fix foreign key error when running migration

前端 未结 2 1794
醉话见心
醉话见心 2021-01-26 12:34

I don\'t know why it\'s still don\'t work and show this:

Illuminate\\Database\\QueryException : SQLSTATE[HY000]: General error: 1005 Can\'t create tabl

2条回答
  •  暖寄归人
    2021-01-26 13:35

    The problem here is that id_druhu in druh_knihies is defined as bigIncrements and you create doba as unsignedInteger and when using foreign key type should be exactly same. So in this case instead of

    $table->unsignedInteger('doba');
    

    you should use

    $table->unsignedBigInteger('doba');
    

提交回复
热议问题