Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-853

Mysql: Drop schema for entities doesnt work if Database contains already tables with 'enum' Field

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Duplicate
    • Affects Version/s: 2.0-BETA4
    • Fix Version/s: 2.0-RC1
    • Component/s: ORM
    • Security Level: All
    • Labels:
      None
    • Environment:
      Win 7 64Bit; PHP 5.3.3, MYSQL 5.14

      Description

      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.

        Activity

        Hide
        Benjamin Eberlei added a comment -

        Fixed, duplicate of DDC-629

        Show
        Benjamin Eberlei added a comment - Fixed, duplicate of DDC-629

          People

          • Assignee:
            Roman S. Borschel
            Reporter:
            Christian Steinmann
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: