DDC-853: Mysql: Drop schema for entities doesnt work if Database contains already tables with 'enum' Field #1056

Closed
opened 2026-01-22 13:00:26 +01:00 by admin · 2 comments
Owner

Originally created by @doctrinebot on GitHub (Nov 1, 2010).

Jira issue originally created by user schnueggel:

Dropping Entities with:

$tool = new \Doctrine\ORM\Tools\SchemaTool($em);
$classes = array(
  $em->getClassMetadata('Entities\User'),
  $em->getClassMetadata('Entities\Profile')
);
$tool->dropSchema($classes);

throws:
Doctrine\DBAL\DBALException: Unknown database type enum requested, Doctrine\DBAL\Platforms\MySqlPlatform may not support it

The Database already contains some tables with enum fields. But those should not be affected. They have no constraints to the tables managed by the EntityManager

Some debugging brought me to the point that Doctrine2 is trying to drop complete database, even metaclasses where given.

In Doctrine\ORM\Tools\SchemaTool $classes will not be used in any way

    public function dropSchema(array $classes)
    {
        $dropSchemaSql = $this->getDropSchemaSql($classes);
        $conn = $this->_em->getConnection();

        foreach ($dropSchemaSql as $sql) {
            $conn->executeQuery($sql);
        }
    }
// Here $classes will not be used
    public function getDropSchemaSql(array $classes)
    {
        $sm = $this->_em->getConnection()->getSchemaManager();
        $schema = $sm->createSchema();

        $visitor = new \Doctrine\DBAL\Schema\Visitor\DropSchemaSqlCollector($this->_platform);
        /** @var $schema \Doctrine\DBAL\Schema\Schema **/
        $schema->visit($visitor);
        return $visitor->getQueries();
    }

Also method SchemaTool::_getDropSchemaTablesDatabaseMode($classes) seems not to be used.

Originally created by @doctrinebot on GitHub (Nov 1, 2010). Jira issue originally created by user schnueggel: Dropping Entities with: ``` java $tool = new \Doctrine\ORM\Tools\SchemaTool($em); $classes = array( $em->getClassMetadata('Entities\User'), $em->getClassMetadata('Entities\Profile') ); $tool->dropSchema($classes); ``` **throws:** Doctrine\DBAL\DBALException: Unknown database type enum requested, Doctrine\DBAL\Platforms\MySqlPlatform may not support it The Database already contains some tables with enum fields. But those should not be affected. They have no constraints to the tables managed by the EntityManager Some debugging brought me to the point that Doctrine2 is trying to drop complete database, even metaclasses where given. In Doctrine\ORM\Tools\SchemaTool $classes will not be used in any way ``` java public function dropSchema(array $classes) { $dropSchemaSql = $this->getDropSchemaSql($classes); $conn = $this->_em->getConnection(); foreach ($dropSchemaSql as $sql) { $conn->executeQuery($sql); } } // Here $classes will not be used public function getDropSchemaSql(array $classes) { $sm = $this->_em->getConnection()->getSchemaManager(); $schema = $sm->createSchema(); $visitor = new \Doctrine\DBAL\Schema\Visitor\DropSchemaSqlCollector($this->_platform); /** @var $schema \Doctrine\DBAL\Schema\Schema **/ $schema->visit($visitor); return $visitor->getQueries(); } ``` Also method SchemaTool::_getDropSchemaTablesDatabaseMode($classes) seems not to be used.
admin added the Bug label 2026-01-22 13:00:26 +01:00
admin closed this issue 2026-01-22 13:00:27 +01:00
Author
Owner

@doctrinebot commented on GitHub (Nov 16, 2010):

Comment created by @beberlei:

Fixed, duplicate of DDC-629

@doctrinebot commented on GitHub (Nov 16, 2010): Comment created by @beberlei: Fixed, duplicate of [DDC-629](http://www.doctrine-project.org/jira/browse/DDC-629)
Author
Owner

@doctrinebot commented on GitHub (Nov 16, 2010):

Issue was closed with resolution "Duplicate"

@doctrinebot commented on GitHub (Nov 16, 2010): Issue was closed with resolution "Duplicate"
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#1056