protected function execute(InputInterface $input, OutputInterface $output)
 {
     $runner = new MigrationRunner($this->neptune['db'], new ConsoleLogger($output));
     $module = $this->getModuleArgument($input, $output);
     $runner->migrateLatest($module);
     $output->writeln(sprintf('Migrated <info>%s</info> to the latest version.', $module->getName()));
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $runner = new MigrationRunner($this->neptune['db'], new ConsoleLogger($output));
     if ($input->getOption('force')) {
         $runner->ignoreExceptions();
     }
     $module = $this->getModuleArgument($input, $output);
     $version = $input->getArgument('version');
     if (!$version && $version !== '0') {
         //no version has been specified, so prompt for a version
         //by displaying all available migrations, highlighting the
         //current version.
         $migrations = $this->getMigrationsWithHighlight($runner, $module);
         $messages = array_values($migrations);
         $versions = array_keys($migrations);
         $prompt = sprintf('Select a migration for module <info>%s</info>:', $module->getName());
         $dialog = $this->getHelper('dialog');
         $index = $dialog->select($output, $prompt, $messages);
         $version = $versions[$index];
     }
     $current = $runner->getCurrentVersion($module);
     if ((int) $version === (int) $current) {
         $output->writeln("Database is already at version {$version}");
         return true;
     }
     $runner->migrate($module, $version);
 }
 /**
  * Get a list of all available migrations in a module, most recent
  * first, highlighting the current version. Each list entry
  * contains the version number and the migration description.
  */
 protected function getMigrationsWithHighlight(MigrationRunner $runner, AbstractModule $module)
 {
     $available = $runner->getAllMigrations($module);
     $current_version = $runner->getCurrentVersion($module);
     $migrations = array_map(function ($migration) use($current_version) {
         if ($migration->getVersion() === $current_version) {
             return sprintf('<info>%s %s</info>', $migration->getVersion(), $migration->getDescription());
         }
         return sprintf('%s %s', $migration->getVersion(), $migration->getDescription());
     }, $available);
     $zero = '             0 Revert all migrations';
     if ($current_version === 0) {
         $zero = '<info>' . $zero . '</info>';
     }
     $migrations = [$zero] + $migrations;
     return $migrations;
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $runner = new MigrationRunner($this->neptune['db'], new ConsoleLogger($output));
     if ($input->getOption('force')) {
         $runner->ignoreExceptions();
     }
     foreach ($this->neptune->getModules() as $module) {
         try {
             $runner->migrateLatest($module);
             $output->writeln(sprintf('Module <info>%s</info> up to date', $module->getName()));
         } catch (MigrationNotFoundException $e) {
             //this means the module doesn't have a migrations
             //folder, so skip it
             continue;
         }
     }
 }