function run_rollback($task, $args) { if (count($args) == 0) { throw new Exception('You must provide a app.'); } @(list($app, $env) = explode(':', $args[0])); if (!is_dir(sfConfig::get('sf_app_dir') . DIRECTORY_SEPARATOR . $app)) { throw new Exception('The app "' . $app . '" does not exist.'); } // define constants define('SF_ROOT_DIR', sfConfig::get('sf_root_dir')); define('SF_APP', $app); define('SF_ENVIRONMENT', $env ? $env : 'cli'); define('SF_DEBUG', true); // get configuration require_once SF_ROOT_DIR . DIRECTORY_SEPARATOR . 'apps' . DIRECTORY_SEPARATOR . SF_APP . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'config.php'; $databaseManager = new sfDatabaseManager(); $databaseManager->initialize(); $migrator = new sfMigrator(); $count = $migrator->rollback(1); $currentVersion = $migrator->getCurrentVersion(); pake_echo_action('migrations', 'migrated ' . $count . ' step(s)'); pake_echo_action('migrations', 'current database version: ' . $currentVersion); }