Skip to content

Loading…

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

Closed
doctrinebot opened this Issue · 2 comments

1 participant

@doctrinebot

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.

@doctrinebot

Comment created by @beberlei:

Fixed, duplicate of DDC-629

@doctrinebot

Issue was closed with resolution "Duplicate"

@doctrinebot doctrinebot added this to the 2.0-RC1 milestone
@doctrinebot doctrinebot closed this
@doctrinebot doctrinebot added the Bug label
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.