gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-29 06:57:10 25 4
gpt4 key购买 nike

尝试更改表“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');
});

更改字段属性值的正确方法吗?

我收到运行时异常'更改表“role_users”的列需要 Doctrine DBAL';

最佳答案

您需要安装以下软件包:

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

那里提到了:

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:

关于mysql - 将表字段的属性值更改为 UNSIGNED - Mysql laravel 迁移,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45140307/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com