Last active
December 18, 2017 21:20
-
-
Save gapple/48ab2dc5424dc3408166 to your computer and use it in GitHub Desktop.
Run a single module update hook via Drush https://gapple.github.io/drush-plugins/
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 | |
function update_rerun_drush_command() { | |
$commands = array(); | |
$commands['update_rerun'] = array( | |
'description' => 'Rerun an update hook for a module', | |
'aliases' => array('urr'), | |
'arguments' => array( | |
'module' => 'Module', | |
'version' => 'Update hook number', | |
), | |
'required-arguments' => TRUE, | |
'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_FULL, | |
); | |
return $commands; | |
} | |
function drush_update_rerun($module, $version) { | |
if (!module_load_install($module)) { | |
drush_log('Unable to load ' . $module .'.install', 'error'); | |
return; | |
} | |
$update_hooks = drupal_get_schema_versions($module); | |
if (empty($update_hooks) || !in_array($version, $update_hooks)) { | |
drush_log('Update hook unavailable', 'error'); | |
return; | |
} | |
$function = $module . '_update_' . $version; | |
$function(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Now in its own repository: https://github.com/gapple/drush-update-rerun