问题
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