2017-07-17 191 views
-1

試圖改變表「ROLE_USER」改變現場「user_id說明」的屬性爲「無符號」添加一個外鍵約束修改表字段的屬性值UNSIGNED - Mysql的laravel遷移

Schema::table('role_user', function (Blueprint $table) { 
      $table->integer('user_id')->unsigned()->nullable()->change(); 
      $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade'); 
     }); 

是不是正確的方式改變字段的屬性值?

我正在運行時異常'Changing columns for table "role_users" requires Doctrine DBAL';

回答

1

您需要安裝以下包:從理論

composer require doctrine/dbal 

DABL包允許你修改列。 http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/introduction.html

還檢查了修改列部分: https://laravel.com/docs/5.3/migrations

它提到在那裏:

修改列之前,請務必學說/ DBAL依賴添加到您的composer.json文件。 Doctrine DBAL庫用於確定列的當前狀態並創建對列進行指定調整所需的SQL查詢: