Unknown database type enum requested
First of all thank you for this great package. I am currently testing it on a big project we have. But I get the following output:
Unknown database type enum requested, Doctrine\DBAL\Platforms\MySQL80Platform may not support it.
at vendor/doctrine/dbal/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php:454
450▕
451▕ $dbType = strtolower($dbType);
452▕
453▕ if (! isset($this->doctrineTypeMapping[$dbType])) {
➜ 454▕ throw new Exception(
455▕ 'Unknown database type ' . $dbType . ' requested, ' . static::class . ' may not support it.'
456▕ );
457▕ }
458▕
+22 vendor frames
23 artisan:37
Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
I researched a bit and found the following issue: https://github.com/doctrine/dbal/issues/3161
A suggested solution is mapping it to varchars:
You can map ENUMs to varchars. You can register MySQL ENUMs to map to Doctrine varchars. This way Doctrine always resolves ENUMs to Doctrine varchars. It will even detect this match correctly when using SchemaTool update commands.
What would be the best place to put this?
$conn = $em->getConnection();
$conn->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'string');
I also tested to only export tables where aren't any enums, but unfortunately it doesn't work.
This worked for me, extended \BeyondCode\LaravelMaskedDumper\DumpSchema and replaced getConnection()
then in config/masked-dump.php i reference the new class instead of the package class
<?php namespace App\Database\Migrations;
use Doctrine\DBAL\Exception;
use Illuminate\Database\ConnectionInterface;
class DumpSchema extends \BeyondCode\LaravelMaskedDumper\DumpSchema
{
/**
* @return ConnectionInterface
* @throws Exception
*/
public function getConnection(): ConnectionInterface
{
$connection = parent::getConnection();
$connection->getDoctrineSchemaManager()->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'string');
return $connection;
}
}