当我跑:
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可能不支持它。
试试这个解决方案可能会对你有用,
public function __construct()
{
DB::getDoctrineSchemaManager()->getDatabasePlatform()->registerDoctrineTypeMapping('json', 'text');
}
有关此问题的进一步阅读,请在laravel repo查看Issue #15772
有同样的问题: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