“请求未知的数据库类型json,Doctrine \ DBAL \ Platforms \ MySQL57Platform可能不支持它。”运行php artisan migrate命令时

问题描述 投票:3回答:2

当我跑:

php artisan migrate

并希望将字符串字段修改为文本字段,如下所示:

//the old field that i want to modify in migration file
$table->string('description')->nullable();

//and the new text field
$table->text('description')->change();

我收到以下错误:

请求未知的数据库类型json,Doctrine \ DBAL \ Platforms \ MySQL57Platform可能不支持它。

laravel laravel-5.4
2个回答
8
投票

试试这个解决方案可能会对你有用,

public function __construct()
{
    DB::getDoctrineSchemaManager()->getDatabasePlatform()->registerDoctrineTypeMapping('json', 'text');
}

有关此问题的进一步阅读,请在laravel repo查看Issue #15772


2
投票

有同样的问题:Unknown database type json requested, Doctrine\DBAL\Platforms\MySqlPlatform may not support it.

原因 - 我的应用程序的serverVersion=5.5文件中有serverVersion=5.7而不是.env,当doctrine 2.6+由作曲家安装时。

所以对DATABASE_URL将是:DATABASE_URL=mysql://[email protected]/database_%kernel.environment%?serverVersion=5.7

© www.soinside.com 2019 - 2024. All rights reserved.