亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

外鍵不遷移。我在遷移方面遇到一些問題。我已經很好地遷移了公司表

外鍵不遷移。我在遷移方面遇到一些問題。我已經很好地遷移了公司表

PHP
溫溫醬 2023-07-01 10:09:08
這是我的代碼Schema::create('employees', function (Blueprint $table) {            $table->id();            $table->string('first_name');            $table->text('second_name');            $table->string('emp_company')->unsigned();            $table->string('email');            $table->string('phone');            $table->timestamps();            $table->foreign('emp_company')->references('company_name')->on('companies');        });這是我的錯誤:SQLSTATE[42000]: 語法錯誤或訪問沖突: 1064 您的 SQL 語法有錯誤;檢查與您的 MariaDB 服務器版本相對應的手冊,了解在第 1 行“unsigned not null, emailvarchar(255) not null, varchar(255) not null,”附近使用的正確語法(SQL: create table ( bigint unsigned not null auto_increment 主鍵、varchar(255) not null、text not null、varchar(255) unsigned not null、varchar(255) not null、varchar(255) not null、timestamp null、timestamp null) 默認字符集 utf8mb4 collate 'utf8mb4_unicode_ci ')phoneemployeesidfirst_namesecond_nameemp_companyemailphonecreated_atupdated_at我堅持這個..尋找支持謝謝。
查看完整描述

1 回答

?
三國紛爭

TA貢獻1804條經驗 獲得超7個贊

我認為你的問題在這一行:

 $table->string('emp_company')->unsigned();

unsigned 僅用于數字列,強制只使用正數,字符串列沒有 UNSIGNED,沒有意義

只需刪除 ->unsigned() 并且您的代碼應該可以工作......


查看完整回答
反對 回復 2023-07-01
  • 1 回答
  • 0 關注
  • 140 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號