“Unknown database type json requested, Doctrine\DBAL\Platforms\MySQL57Platform may not support it.” while running php artisan migrate command

不羁岁月 提交于 2019-12-10 09:32:30

问题


When I run:

php artisan migrate

and want to modify a string field to a text field like this:

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

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

I get the following error:

Unknown database type json requested, Doctrine\DBAL\Platforms\MySQL57Platform may not support it.


回答1:


try this solution may be this will work for you,

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

For further reading about this issue check Issue #15772 at laravel repo




回答2:


Had same issue: Unknown database type json requested, Doctrine\DBAL\Platforms\MySqlPlatform may not support it..

The reason - I had serverVersion=5.5 rather than serverVersion=5.7 at my app's .env file, when doctrine 2.6+ was installed by composer.

So right DATABASE_URL will be: DATABASE_URL=mysql://root@127.0.0.1/database_%kernel.environment%?serverVersion=5.7




回答3:


If using Symfony, you have to make sure your dbal config is pointing at the correct server version:

# Doctrine Configuration
doctrine:
  dbal:
    driver: pdo_mysql
    host: "%database_host%"
    port: "%database_port%"
    dbname: "%database_name%"
    user: "%database_user%"
    password: "%database_password%"
    charset: utf8mb4
    server_version: 5.7
    default_table_options:
      charset: utf8mb4
      collate: utf8mb4_unicode_ci
      engine: InnoDB


来源:https://stackoverflow.com/questions/48256476/unknown-database-type-json-requested-doctrine-dbal-platforms-mysql57platform-m

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!