symfony: doctrine-messenger failes to create table with "Unknown database type enum requested"

Symfony version(s) affected

6.2

Description

I’m trying to use doctrine-messenger in a database where are some legacy tables that aren’t even mapped to entites and have enum fields. On messenger first start (when it tries to create the messenger_messages table) it scans all my tables and dies if finds anything with an enum field.

Stack:

In AbstractPlatform.php line 441:
                                                                                                     
  [Doctrine\DBAL\Exception]                                                                          
  Unknown database type enum requested, Doctrine\DBAL\Platforms\MySQL80Platform may not support it.  
                                                                                                     

Exception trace:
  at /var/www/html/vendor/doctrine/dbal/src/Platforms/AbstractPlatform.php:441
 Doctrine\DBAL\Platforms\AbstractPlatform->getDoctrineTypeMapping() at /var/www/html/vendor/doctrine/dbal/src/Schema/MySQLSchemaManager.php:186
 Doctrine\DBAL\Schema\MySQLSchemaManager->_getPortableTableColumnDefinition() at /var/www/html/vendor/doctrine/dbal/src/Schema/AbstractSchemaManager.php:1408
 Doctrine\DBAL\Schema\AbstractSchemaManager->_getPortableTableColumnList() at /var/www/html/vendor/doctrine/dbal/src/Schema/AbstractSchemaManager.php:423
 Doctrine\DBAL\Schema\AbstractSchemaManager->doListTables() at /var/www/html/vendor/doctrine/dbal/src/Schema/MySQLSchemaManager.php:66
 Doctrine\DBAL\Schema\MySQLSchemaManager->listTables() at /var/www/html/vendor/doctrine/dbal/src/Schema/AbstractSchemaManager.php:1651
 Doctrine\DBAL\Schema\AbstractSchemaManager->createSchema() at /var/www/html/vendor/symfony/doctrine-messenger/Transport/Connection.php:473
 Symfony\Component\Messenger\Bridge\Doctrine\Transport\Connection->updateSchema() at /var/www/html/vendor/symfony/doctrine-messenger/Transport/Connection.php:282
 Symfony\Component\Messenger\Bridge\Doctrine\Transport\Connection->setup() at /var/www/html/vendor/symfony/doctrine-messenger/Transport/Connection.php:243
 Symfony\Component\Messenger\Bridge\Doctrine\Transport\Connection->get() at /var/www/html/vendor/symfony/doctrine-messenger/Transport/DoctrineReceiver.php:45
 Symfony\Component\Messenger\Bridge\Doctrine\Transport\DoctrineReceiver->get() at /var/www/html/vendor/symfony/doctrine-messenger/Transport/DoctrineTransport.php:42
 Symfony\Component\Messenger\Bridge\Doctrine\Transport\DoctrineTransport->get() at /var/www/html/vendor/symfony/messenger/Worker.php:103
 Symfony\Component\Messenger\Worker->run() at /var/www/html/vendor/symfony/messenger/Command/ConsumeMessagesCommand.php:229
 Symfony\Component\Messenger\Command\ConsumeMessagesCommand->execute() at /var/www/html/vendor/symfony/console/Command/Command.php:312
 Symfony\Component\Console\Command\Command->run() at /var/www/html/vendor/symfony/console/Application.php:1040
 Symfony\Component\Console\Application->doRunCommand() at /var/www/html/vendor/symfony/framework-bundle/Console/Application.php:88
 Symfony\Bundle\FrameworkBundle\Console\Application->doRunCommand() at /var/www/html/vendor/symfony/console/Application.php:314
 Symfony\Component\Console\Application->doRun() at /var/www/html/vendor/symfony/framework-bundle/Console/Application.php:77
 Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at /var/www/html/vendor/symfony/console/Application.php:168
 Symfony\Component\Console\Application->run() at /var/www/html/vendor/symfony/runtime/Runner/Symfony/ConsoleApplicationRunner.php:54
 Symfony\Component\Runtime\Runner\Symfony\ConsoleApplicationRunner->run() at /var/www/html/vendor/autoload_runtime.php:29
 require_once() at /var/www/html/bin/console:11

I don’t understand why is it matter to doctrine (dbal andor messenger) what other tables I have in my DB, that has nothing to do with it.

regards, mmarton

How to reproduce

  1. Have a table with an enum field in your db.
  2. install doctrine-messenger
  3. try to start it.

Possible Solution

Adding mapping types config prevents the issue:

dbal:
    mapping_types:
        enum: string

Manually creating the table works too.

Additional Context

symfony 6.2 php 8.1 mysql 8.0

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 15 (7 by maintainers)

Commits related to this issue

Most upvoted comments

Thanks for the reproducer, I was able to reproduce. I had a quick look and indeed, the current logic relies on the schema comparator, which needs to load the existing tables so that it can then figure out if the messenger table should be created before creating it.

We could simplify this logic by only checking if this specific table exists, and if not, create if with its indexes and sequences.

Help wanted.