laravel errno 150 foreign key constraint is incorrectly formed

前端 未结 11 1564
陌清茗
陌清茗 2020-12-14 03:09

Can anybody help me to solve this problem?

There are 3 tables with 2 foreign keys:

Schema::create(\'users\', function (Blueprint $table) {
    $table-&         


        
11条回答
  •  猫巷女王i
    2020-12-14 04:00

    In case of foreign keys, the referenced and referencing fields must have exactly the same data type.

    You create the id fields in both users and firms as signed integers. However, you create both foreign keys as unsigned integers, therefore the creation of the keys fail.

    You need to either add the unsigned clause to the id field definitions, or remove the unsigned clause from the foreign key fields.

提交回复
热议问题