/**
  * Do the configured migrations in the given migration file for the given workspace
  *
  * By default the up direction is applied, using the direction parameter this can
  * be changed.
  *
  * @param string $workspace The name of the workspace you want to migrate. This workspace must exist.
  * @param string $version The version of the migration configuration you want to use.
  * @param boolean $confirmation Confirm application of this migration, only needed if the given migration contains any warnings.
  * @param string $direction The direction to work in, MigrationStatus::DIRECTION_UP or MigrationStatus::DIRECTION_DOWN
  * @return void
  */
 public function migrateCommand($workspace, $version, $confirmation = FALSE, $direction = MigrationStatus::DIRECTION_UP)
 {
     $context = $this->prepareContext($workspace);
     $migrationConfiguration = $direction === MigrationStatus::DIRECTION_UP ? $this->migrationFactory->getMigrationForVersion($version)->getUpConfiguration() : $this->migrationFactory->getMigrationForVersion($version)->getDownConfiguration();
     $this->outputCommentsAndWarnings($migrationConfiguration);
     if ($migrationConfiguration->hasWarnings() && $confirmation === FALSE) {
         $this->outputLine();
         $this->outputLine('Migration has warnings. You need to confirm execution by adding the "--confirmation TRUE" option to the command.');
         $this->quit(1);
     }
     $nodeMigrationService = new NodeMigration($context, $migrationConfiguration->getMigration());
     switch ($direction) {
         case MigrationStatus::DIRECTION_UP:
             $nodeMigrationService->migrateUp();
             break;
         case MigrationStatus::DIRECTION_DOWN:
             $nodeMigrationService->migrateDown();
             break;
         default:
     }
     $migrationStatus = new MigrationStatus($version, $workspace, $direction, new \DateTime());
     $this->migrationStatusRepository->add($migrationStatus);
     $this->outputLine();
     $this->outputLine('Successfully applied migration.');
 }
 /**
  * List available and applied migrations
  *
  * @return void
  * @see typo3.typo3cr.migration:node:listavailablemigrations
  */
 public function migrationStatusCommand()
 {
     $this->outputLine();
     $availableMigrations = $this->migrationFactory->getAvailableMigrationsForCurrentConfigurationType();
     if (count($availableMigrations) === 0) {
         $this->outputLine('No migrations available.');
         $this->quit();
     }
     $appliedMigrations = $this->migrationStatusRepository->findAll();
     $appliedMigrationsDictionary = array();
     /** @var $appliedMigration MigrationStatus */
     foreach ($appliedMigrations as $appliedMigration) {
         $appliedMigrationsDictionary[$appliedMigration->getVersion()][] = $appliedMigration;
     }
     $tableRows = array();
     foreach ($availableMigrations as $version => $migration) {
         $migrationUpConfigurationComments = $this->migrationFactory->getMigrationForVersion($version)->getUpConfiguration()->getComments();
         if (isset($appliedMigrationsDictionary[$version])) {
             $applicationInformation = $this->phraseMigrationApplicationInformation($appliedMigrationsDictionary[$version]);
             if ($applicationInformation !== '') {
                 $migrationUpConfigurationComments .= PHP_EOL . '<b>Applied:</b>' . PHP_EOL . $applicationInformation;
             }
         }
         $tableRows[] = array($version, $migration['formattedVersionNumber'], $migration['package']->getPackageKey(), wordwrap($migrationUpConfigurationComments, 60));
     }
     $this->outputLine('<b>Available migrations</b>');
     $this->outputLine();
     $this->output->outputTable($tableRows, array('Version', 'Date', 'Package', 'Comments'));
 }