将 table 字段的属性值更改为 UNSIGNED - Mysql laravel 迁移

Alter table field's attribute value to UNSIGNED - Mysql laravel migration

正在尝试更改 table 'role_user' 以将字段 'user_id' 属性更改为 'unsigned' 以添加外键约束

 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';

您需要安装以下软件包:

composer require doctrine/dbal

来自 doctrine 的 DABL 包允许您修改列。 http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/introduction.html

另请查看修改列部分: https://laravel.com/docs/5.3/migrations

那里提到了它:

Before modifying a column, be sure to add the doctrine/dbal dependency to your composer.json file. The Doctrine DBAL library is used to determine the current state of the column and create the SQL queries needed to make the specified adjustments to the column: