/** * Executes UP method for the given migrations * * @param MigrationState[] $migrations * @param bool $dryRun * * @throws \RuntimeException if at lease one migration failed */ public function executeUp(array $migrations, $dryRun = false) { $platform = $this->queryExecutor->getConnection()->getDatabasePlatform(); $sm = $this->queryExecutor->getConnection()->getSchemaManager(); $schema = $this->createSchemaObject($sm->listTables(), $platform->supportsSequences() ? $sm->listSequences() : [], $sm->createSchemaConfig()); $failedMigrations = false; foreach ($migrations as $item) { $migration = $item->getMigration(); if (!empty($failedMigrations) && !$migration instanceof FailIndependentMigration) { $this->logger->notice(sprintf('> %s - skipped', get_class($migration))); continue; } if ($this->executeUpMigration($schema, $platform, $migration, $dryRun)) { $item->setSuccessful(); } else { $item->setFailed(); $failedMigrations[] = get_class($migration); } } if (!empty($failedMigrations)) { throw new \RuntimeException(sprintf('Failed migrations: %s.', implode(', ', $failedMigrations))); } }