Enable a module before drush updatedb runs.. via that module

hefox's picture

in mymodule.drush.inc

<?php
/**
* Implementation of drush_hook_pre_updatedb().
*/
function drush_mymodule_pre_updatedb() {
 
drush_bootstrap_max();
  if (!
module_exists('mymodule')) {
   
module_enable(array('mymodule'));
  }
}
?>

Comments

The takeaway is that Drush

Garrett Albright's picture

The takeaway is that Drush calls the drush_hook_pre_updatedb() (and possibly other Drush hooks?) of disabled modules, which these modules can take advantage of to enable themselves.

I chatted with hefox about this on IRC. I personally am leaning toward this being a bug (or "unintended feature") in Drush, but hefox thinks it makes sense in terms of creating Drush-only modules…

This recently changed in

moshe weitzman's picture

This recently changed in Drush HEAD. If your command does a BOOTSTRAP_FULL, only enabled modules can participate in drush_invoke() hooks like pre_updatedb. If the command bootstraps to a couple levels lower, drush commandfiles are indeed eligible to hook in. See http://drupal.org/node/861822#comment-3319040 and later comments.

In Drush 3, you are correct that commandfiles in disabled modules are in play for hooks for all drush commands.

Drupal for Evil

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: