コード例 #1
0
 /**
  * @param Schema           $schema
  * @param AbstractPlatform $platform
  * @param Migration        $migration
  * @param bool             $dryRun
  *
  * @return bool
  */
 public function executeUpMigration(Schema &$schema, AbstractPlatform $platform, Migration $migration, $dryRun = false)
 {
     $result = true;
     $this->logger->notice(sprintf('> %s', get_class($migration)));
     $toSchema = clone $schema;
     $this->setExtensions($migration);
     try {
         $queryBag = new QueryBag();
         $migration->up($toSchema, $queryBag);
         $comparator = new Comparator();
         $schemaDiff = $comparator->compare($schema, $toSchema);
         $this->checkTables($schemaDiff, $migration);
         $this->checkIndexes($schemaDiff, $migration);
         $queries = array_merge($queryBag->getPreQueries(), $schemaDiff->toSql($platform), $queryBag->getPostQueries());
         $schema = $toSchema;
         foreach ($queries as $query) {
             $this->queryExecutor->execute($query, $dryRun);
         }
     } catch (\Exception $ex) {
         $result = false;
         $this->logger->error(sprintf('  ERROR: %s', $ex->getMessage()));
     }
     return $result;
 }