久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

laravel errno 150 外鍵約束的格式不正確

laravel errno 150 foreign key constraint is incorrectly formed(laravel errno 150 外鍵約束的格式不正確)
本文介紹了laravel errno 150 外鍵約束的格式不正確的處理方法,對大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

誰能幫我解決這個(gè)問題?

Can anybody help me to solve this problem?

有 3 個(gè)表,有 2 個(gè)外鍵:

There are 3 tables with 2 foreign keys:

Schema::create('users', function (Blueprint $table) {
    $table->increments('id');
    $table->string('name');
    $table->string('email')->unique();
    $table->string('password');
    $table->rememberToken();
    $table->timestamps();
});

Schema::create('firms', function (Blueprint $table) {
    $table->increments('id');
    $table->string('title')->nullable();
    $table->integer('user_id')->unsigned()->nullable();
    $table->foreign('user_id')->references('id')->on('users');
    $table->timestamps();
});

Schema::create('jobs', function (Blueprint $table) {
    $table->increments('id');
    $table->string('title')->nullable();
    $table->integer('firm_id')->unsigned()->nullable();
    $table->foreign('firm_id')->references('id')->on('firms');
    $table->timestamps();
});
                    

運(yùn)行遷移后出錯(cuò):

[IlluminateDatabaseQueryException]
  SQLSTATE[HY000]: General error: 1005 Can't create table `job`.`#sql-5fc_a1`
   (errno: 150 "Foreign key constraint is incorrectly formed") (SQL: alter ta
  ble `firms` add constraint `firms_user_id_foreign` foreign key (`user_id`)
  references `users` (`id`))

  [PDOException]
  SQLSTATE[HY000]: General error: 1005 Can't create table `job`.`#sql-5fc_a1`
   (errno: 150 "Foreign key constraint is incorrectly formed")

推薦答案

如果是外鍵,引用字段和引用字段的數(shù)據(jù)類型必須完全相同.

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

您將usersfirms 中的id 字段創(chuàng)建為有符號 整數(shù).但是,您將兩個(gè)外鍵創(chuàng)建為無符號 整數(shù),因此鍵的創(chuàng)建失敗.

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.

您需要將 unsigned 子句添加到 id 字段定義中,或者從外鍵字段中刪除 unsigned 子句.

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

這篇關(guān)于laravel errno 150 外鍵約束的格式不正確的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

Laravel Eloquent Union query(Laravel Eloquent Union 查詢)
Overwrite laravel 5 helper function(覆蓋 Laravel 5 輔助函數(shù))
laravel querybuilder how to use like in wherein function(laravel querybuilder 如何在 where 函數(shù)中使用 like)
The Response content must be a string or object implementing __toString(), quot;booleanquot; given after move to psql(響應(yīng)內(nèi)容必須是實(shí)現(xiàn) __toString()、“boolean和“boolean的字符串或?qū)ο?移動到 psql 后給出) - IT屋-程
Roles with laravel 5, how to allow only admin access to some root(Laravel 5 的角色,如何只允許管理員訪問某些根)
Laravel Auth - use md5 instead of the integrated Hash::make()(Laravel Auth - 使用 md5 而不是集成的 Hash::make())
主站蜘蛛池模板: 国产精品久久久久久久久久妇女 | 一区二区三区四区在线免费观看 | 欧美日高清视频 | 精品乱码一区二区三四区视频 | 中文字幕一区二区三区在线观看 | 日韩在线精品 | 一区二区视频 | 成人三区| 中文字幕在线第一页 | 国产精品日韩欧美一区二区三区 | 久久久国产一区 | 91精品在线播放 | 91新视频 | 麻豆精品国产免费 | 国产成人99久久亚洲综合精品 | 91精品久久久久久久久 | 视频在线一区二区 | 亚洲国产精品成人综合久久久 | 日韩av电影在线观看 | 久久久网 | 最新中文字幕在线 | 久久蜜桃av一区二区天堂 | 久久噜噜噜精品国产亚洲综合 | 亚洲国产成人精品女人久久久 | 成年人视频免费在线观看 | 欧美日韩久久 | 狠狠躁18三区二区一区 | 黄色一级大片在线免费看产 | www.亚洲国产精品 | 浴室洗澡偷拍一区二区 | 国产高清一区二区三区 | 精品少妇一区二区三区日产乱码 | 国产一区二区在线视频 | 91欧美 | 无码一区二区三区视频 | 亚洲精品永久免费 | 中文字幕在线观看第一页 | 精品一区电影 | 9999精品视频| www久久国产 | 蜜桃视频在线观看免费视频网站www |