Skip to content

Instantly share code, notes, and snippets.

@gapple
Last active December 18, 2017 21:20
Show Gist options
  • Save gapple/48ab2dc5424dc3408166 to your computer and use it in GitHub Desktop.
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/
<?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();
}
@gapple
Copy link
Author

gapple commented May 19, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment