在 Laravel 迁移中更改列会导致异常:更改表的列需要 Doctrine DBAL
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/36780688/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Changing column in Laravel migration causes exception: Changing columns for table requires Doctrine DBAL
提问by Ahmad
I'm trying to change the max length of one of my columns in table reserves
in one migration. The code looks like this:
我正在尝试reserves
在一次迁移中更改表中一列的最大长度。代码如下所示:
public function up()
{
//
Schema::table('reserves', function($table){
$table->string("mobile", 11)->change();
});
}
But when running the migration via artisan, it throws an exception and says:
但是当通过 artisan 运行迁移时,它会抛出一个异常并说:
[RuntimeException] Changing columns for table "reserves" requires Doctrine DBAL; install "doctrine/dbal".
[RuntimeException] 更改表“reserves”的列需要 Doctrine DBAL;安装“学说/dbal”。
What is the problem and how can I solve it?
有什么问题,我该如何解决?
回答by Ahmad
The problem was solved, with executing following command on the root directory of the framework:
问题解决了,在框架的根目录执行以下命令:
composer require doctrine/dbal
回答by majeed21
add to composer.json
添加到 composer.json
"require": {
...
"doctrine/dbal": "*"
},
run "composer update" command
运行“作曲家更新”命令