/**
  * The migrate command.
  *
  * @return bool
  */
 public function migrate()
 {
     $options = array('direction' => $this->args[0], 'scope' => 'app');
     if (isset($this->params['plugin']) && CakePlugin::loaded($this->params['plugin'])) {
         $options['scope'] = $this->params['plugin'];
     }
     if (isset($this->args[1])) {
         $options['steps'] = (int) $this->args[1];
     }
     try {
         $migrations = new Migrations($this->params['connection']);
         $migrations->migrate($options);
     } catch (Exception $e) {
         $this->out(__d('migration_shell', 'An error occured during the migration.'));
         $this->err($e->getMessage());
         return false;
     }
     $this->out(__d('migration_shell', 'The migration was successful.'));
     /** @var SchemaMigration $sm */
     $sm = ClassRegistry::init('Migrations.SchemaMigration');
     $sm->setDataSource($this->params['connection']);
     $this->out(__d('migration_shell', 'Current Migration version: %s', array($sm->getCurrentVersion($options['scope']))));
     $migrations->clearCache();
     return true;
 }