Example #1
0
 /**
  * Execute the task
  *
  * @param array $options Config for the task
  */
 protected function _execute(array $options)
 {
     $model = new Model_Migration();
     $view = new View('minion/db/status');
     $view->groups = $model->get_group_statuses();
     echo $view;
 }
Example #2
0
 /**
  * Migrates the database to the version specified
  *
  * @param array $options Configuration to use
  */
 protected function _execute(array $options)
 {
     $groups = $options['group'];
     $target = $options['to'];
     $dry_run = $options['dry-run'] !== FALSE;
     $quiet = $options['quiet'] !== FALSE;
     $up = $options['up'] !== FALSE;
     $down = $options['down'] !== FALSE;
     $groups = $this->_parse_groups($groups);
     if ($target === NULL) {
         if ($down) {
             $target = FALSE;
         } else {
             $target = TRUE;
         }
     }
     $model = new Model_Migration();
     $model->ensure_table_exists();
     $manager = new Migration(NULL, $model);
     // Sync the available migrations with those in the db
     $manager->sync_migration_files()->set_dry_run($dry_run);
     try {
         // Run migrations for specified groups & versions
         $manager->run_migration($groups, $target);
     } catch (Migration_Exception $e) {
         echo View::factory('minion/db/exception')->set('migration', $e->get_migration())->set('error', $e->getMessage());
         throw $e;
     }
     $view = View::factory('minion/db/run')->set('dry_run', $dry_run)->set('quiet', $quiet)->set('dry_run_sql', $manager->get_dry_run_sql())->set('executed_migrations', $manager->get_executed_migrations())->set('group_versions', $model->get_group_statuses());
     return $view;
 }