public function migrateCommand($version, $confirmation = false, $direction = MigrationStatus::DIRECTION_UP)
    {
        try {
            $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($migrationConfiguration->getMigration());
            $nodeMigrationService->execute();
            $migrationStatus = new MigrationStatus($version, $direction, new \DateTime());
            $this->migrationStatusRepository->add($migrationStatus);
            $this->outputLine();
            $this->outputLine('Successfully applied migration.');
        } catch (MigrationException $e) {
            $this->outputLine();
            $this->outputLine('Error: ' . $e->getMessage());
            $this->quit(1);
        } catch (DatabaseException $exception) {
            $this->outputLine();
            $this->outputLine('An exception occurred during the migration, run a ./flow doctrine:migrate and run the migration again.');
            $this->quit(1);
        }
    }