Je ne sais pas s'il s'agit d'un bogue, mais le changement d'un type de colonne de varchar à json entraîne l'erreur suivante :
Schema::table('fields', function (Blueprint $table) {
$table->json('label')->change();
});
[Doctrine\DBAL\DBALException]
Unknown column type "json" requested. Any Doctrine type that you use has to be registered
with \Doctrine\DBAL\Types\Type::addType(). You can get a list of all the known types with
\Doctrine\DBAL\Types\Type::getTypesMap(). If this error occurs during database introspecti
on then you might have forgot to register all database types for a Doctrine Type. Use Abst
ractPlatform#registerDoctrineTypeMapping() or have your custom types implement Type#getMap
pedDatabaseTypes(). If the type name is empty you might have a problem with the cache or f
orgot some mapping information.
Utiliser $table->text('label')->change();
la place ?
Le problème réside dans Doctrine DBAL, il ne prend pas encore en charge le type de colonne JSON pour MySQL :
https://github.com/doctrine/dbal/blob/2.0.x/lib/Doctrine/DBAL/Platforms/MySqlPlatform.php#L598
Je ne vois aucun PR pour le moment, mais vous pouvez ajouter des types de carte personnalisés (comme suggéré dans le message d'erreur) :
J'obtiens cette erreur même si j'utilise une base de données PostgreSQL avec Laravel 5.3
$query = "ALTER TABLE fields MODIFY label
JSON DEFAULT NULL" ;
\Illuminate\Support\Facades\DB::statement($query);
Essayez ceci dans la migration laravel .. travailler pour moi
Commentaire le plus utile
J'obtiens cette erreur même si j'utilise une base de données PostgreSQL avec Laravel 5.3