Created
June 14, 2011 23:42
-
-
Save msonnabaum/1026200 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Implementation of hook_drush_command(). | |
*/ | |
function updaterollback_drush_command() { | |
$items['update-get-schema'] = array( | |
'description' => 'Drop all tables in a given database.', | |
'arguments' => array( | |
'module' => 'module', | |
), | |
'bootstrap' => DRUSH_BOOTSTRAP_MAX, | |
); | |
$items['update-rollback'] = array( | |
'description' => '', | |
'arguments' => array( | |
'module' => 'module', | |
'schema' => 'schema', | |
), | |
'bootstrap' => DRUSH_BOOTSTRAP_MAX, | |
); | |
return $items; | |
} | |
function drush_updaterollback_update_rollback($module, $schema = NULL) { | |
require_once './includes/install.inc'; | |
drupal_load_updates(); | |
$current_schema = drupal_get_installed_schema_version($module); | |
$schema = $current_schema - 1; | |
if ($schema) { | |
drupal_set_installed_schema_version($module, $schema - 1); | |
drush_log(dt("!module's schema rolled back to !schema!", array('!module' => $module, '!schema' => $schema))); | |
} | |
else { | |
drush_set_error(dt("!schema is not a valid schema for !module!", array('!schema' => $schema, '!module' => $module))); | |
} | |
} | |
function drush_updaterollback_update_get_schema() { | |
require_once './includes/install.inc'; | |
$modules = func_get_args(); | |
drupal_load_updates(); | |
$schemas = array(); | |
foreach ($modules as $module) { | |
$schemas[$module] = drupal_get_installed_schema_version($module); | |
} | |
drush_print_table(drush_key_value_to_array_table($schemas)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment