第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

無(wú)法添加或更新子行:外鍵約束失敗 - Laravel 7

無(wú)法添加或更新子行:外鍵約束失敗 - Laravel 7

PHP
BIG陽(yáng) 2022-12-23 16:01:50
我正在嘗試1:1在我的訪客和聯(lián)系人之間添加關(guān)系<?phpuse Illuminate\Database\Migrations\Migration;use Illuminate\Database\Schema\Blueprint;use Illuminate\Support\Facades\Schema;class AddRelationToVisitorsDRelationToVisitorsContacts extends Migration{    public function up()    {        Schema::table('contacts', function(Blueprint $table)        {            $table->bigInteger('visitor_id')->unsigned();            $table->foreign('visitor_id')->references('id')->on('visitors')->onDelete('cascade');        });    }    public function down()    {        Schema::table('contacts', function($table)        {            $table->dropForeign('contacts_visitor_id_foreign');            $table->dropColumn('visitor_id');        });        Schema::table('visitors', function(Blueprint $table)        {            $table->dropColumn('contact_id');        });    }}運(yùn)行時(shí)php artisan migrateMigrating: 2020_04_16_104641_update_contacts_table_04_16_2020
查看完整描述

3 回答

?
慕的地10843

TA貢獻(xiàn)1785條經(jīng)驗(yàn) 獲得超8個(gè)贊

在最新版本的 laravel 中,主鍵是 biginteger。所以你可能需要改變這個(gè)

$table->integer('visitor_id')->unsigned();

有了這個(gè)

$table->bigInteger('visitor_id')->unsigned();


查看完整回答
反對(duì) 回復(fù) 2022-12-23
?
呼喚遠(yuǎn)方

TA貢獻(xiàn)1856條經(jīng)驗(yàn) 獲得超11個(gè)贊

visitors 表中的 id 字段應(yīng)該是bigIncrement類型



查看完整回答
反對(duì) 回復(fù) 2022-12-23
?
FFIVE

TA貢獻(xiàn)1797條經(jīng)驗(yàn) 獲得超6個(gè)贊

如果您的表有數(shù)據(jù),最好將已存在數(shù)據(jù)的列值設(shè)置為空,或?qū)⒃摿性O(shè)置為可為空。

$table->bigInteger('visitor_id')->unsigned()->nullable();


查看完整回答
反對(duì) 回復(fù) 2022-12-23
  • 3 回答
  • 0 關(guān)注
  • 120 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)