Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Labels:
      None

      Description

      When iterating migration versions, a call to SchemaManager::createSchema() is done for every versions. Four our schema, this call take about 1 second to execute. With already 30 migrations, this begin to be a problem.

      $versions = $configuration->registerMigrationsFromDirectory($this->_migration_folder);
      foreach($versions as $version){
          if(!$version->isMigrated()){
              $version->markMigrated();
          }
      
      }
      

      The problem is in Migrations\Configuration\Configuration::createMigrationTable() which does not set the migrationTableCreated flag when the table already exists.

      public function createMigrationTable()
      {
              $this->validate();
      
              if ($this->migrationTableCreated) {
                  return false;
              }
      
              $schema = $this->connection->getSchemaManager()->createSchema();
              if ( ! $schema->hasTable($this->migrationsTableName)) {
                  $columns = array(
                      'version' => new Column('version', Type::getType('string'), array('length' => 14)),
                  );
                  $table = new Table($this->migrationsTableName, $columns);
                  $table->setPrimaryKey(array('version'));
                  $this->connection->getSchemaManager()->createTable($table);
      
                  $this->migrationTableCreated = true;
      
                  return true;
              }
              return false;
      }
      

        Activity

        Eric Durand-Tremblay created issue -
        Eric Durand-Tremblay made changes -
        Field Original Value New Value
        Description When iterating migration versions, a call to SchemaManager::createSchema() is done for every versions. Four our schema, this call take about 1 second to execute. With already 30 migrations, this begin to be a problem.

        {code}
        $versions = $configuration->registerMigrationsFromDirectory($this->_migration_folder);
        foreach($versions as $version){
            if(!$version->isMigrated()){
                $version->markMigrated();
            }

        }
        {code}

        The problem is in Migrations\Configuration\Configuration::createMigrationTable() which does not set the migrationTableCreated flag when the table already exists.

        {code}
        public function createMigrationTable()
        {
                $this->validate();

                if ($this->migrationTableCreated) {
                    return false;
                }

                $schema = $this->connection->getSchemaManager()->createSchema();
                if ( ! $schema->hasTable($this->migrationsTableName)) {
                    $columns = array(
                        'version' => new Column('version', Type::getType('string'), array('length' => 14)),
                    );
                    $table = new Table($this->migrationsTableName, $columns);
                    $table->setPrimaryKey(array('version'));
                    $this->connection->getSchemaManager()->createTable($table);

                    $this->migrationTableCreated = true;

                    return true;
                }
                return false;
        }
        {code}
        When iterating migration versions, a call to SchemaManager::createSchema() is done for every versions. Four our schema, this call take about 1 second to execute. With already 30 migrations, this begin to be a problem.


        {code}
        $versions = $configuration->registerMigrationsFromDirectory($this->_migration_folder);
        foreach($versions as $version){
            if(!$version->isMigrated()){
                $version->markMigrated();
            }

        }
        {code}


        The problem is in Migrations\Configuration\Configuration::createMigrationTable() which does not set the migrationTableCreated flag when the table already exists.


        {code}
        public function createMigrationTable()
        {
                $this->validate();

                if ($this->migrationTableCreated) {
                    return false;
                }

                $schema = $this->connection->getSchemaManager()->createSchema();
                if ( ! $schema->hasTable($this->migrationsTableName)) {
                    $columns = array(
                        'version' => new Column('version', Type::getType('string'), array('length' => 14)),
                    );
                    $table = new Table($this->migrationsTableName, $columns);
                    $table->setPrimaryKey(array('version'));
                    $this->connection->getSchemaManager()->createTable($table);

                    $this->migrationTableCreated = true;

                    return true;
                }
                return false;
        }
        {code}

          People

          • Assignee:
            Benjamin Eberlei
            Reporter:
            Eric Durand-Tremblay
          • Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated: