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

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

遷移:無法在laravel中添加外鍵約束

遷移:無法在laravel中添加外鍵約束

小怪獸愛吃肉 2019-12-09 15:32:45
我試圖在Laravel中創建外鍵,但是當我使用I遷移表artisan時,拋出以下錯誤:[Illuminate\Database\QueryException]SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint (SQL: alter table `priorities` add constraint priorities_user_id_foreign foreign key (`user_id`) references `users` (`id`))     我的遷移代碼是這樣的:優先級遷移文件public function up(){    //    Schema::create('priorities', function($table) {        $table->increments('id', true);        $table->integer('user_id');        $table->foreign('user_id')->references('id')->on('users');        $table->string('priority_name');        $table->smallInteger('rank');        $table->text('class');        $table->timestamps('timecreated');    });}/** * Reverse the migrations. * * @return void */public function down(){    //    Schema::drop('priorities');}用戶遷移文件public function up(){    //    Schema::table('users', function($table)    {    $table->create();    $table->increments('id');    $table->string('email');    $table->string('first_name');    $table->string('password');    $table->string('email_code');    $table->string('time_created');    $table->string('ip');    $table->string('confirmed');    $table->string('user_role');    $table->string('salt');    $table->string('last_login');    $table->timestamps();    });}/** * Reverse the migrations. * * @return void */public function down(){    //        Schemea::drop('users');}關于我做錯了什么的任何想法,我想立即得到,因為我需要創建很多表,例如用戶,客戶,項目,任務,狀態,優先級,類型,團隊。理想我想創建與外鍵,i..e持此數據表clients_project和project_tasks等。希望有人可以幫助我入門。
查看完整描述

3 回答

  • 3 回答
  • 0 關注
  • 657 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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