Take the 2-minute tour ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

Can you disable drush pm-update for a particular site in drushrc.php?

I have a server which houses the DEV and LIVE versions of the site. Work is done directly on the DEV site. Changes to the LIVE site are deployed via git pull from a shared remote on the same filesystem.

In an effort to prevent Doing Something Stupid™, and running a pm-update and pm-updatecode on the LIVE site, I would like to disable these commands for that site.

The $command_specific[] syntax allows you to specify persistent options for commands (like --no-core), but I would like to fully disable pm-update and pm-updatecode for this particular site.

Is this possible?

share|improve this question
1  
This won't help with the question, but I'm curious...how are you running db updates if not through drush? Are you pushing the db upstream too? –  Clive Feb 12 at 15:00
    
@Clive Basic procedure is go into maint. mode, git pull, drush updatedb, drush cc all, spot check, go out of maint mode. –  MPD Feb 12 at 15:03
    
Doh, ignore me I read that wrong. Thought you weren't running updatedb on live –  Clive Feb 12 at 15:04
add comment

2 Answers 2

up vote 4 down vote accepted

You can disable the core Update module on the live site, and then should prevent being able run pm-update on live:

$ drush pm-disable update
The following extensions will be disabled: update
Do you really want to continue? (y/n): y
update was disabled successfully. [ok]
$ drush pm-update
Command pm-update needs the following modules installed/enabled to run: update. [error]
The drush command 'pm-update' could not be executed. [error]

share|improve this answer
    
Not sure why I dind't think about that. –  MPD Feb 12 at 15:50
add comment

You can implement drush_hook_pre_COMMAND which says

Run before a specific command executes. Logging an error stops command execution.

Logging an error stops command execution, and the rollback function (if any) for each hook implementation is invoked, in addition to the validate rollback.

By implementing above hook in custom module and throwing an error should disable command.

As said in above answer Disabling module will be best option in above case.. But , I believe above hook will be handy if only drush command need to be disabled instead of module itself.. Most of the cases module disable may not be good option since it's functionality may be required to run drupal.. For example to disable user-add-role command we cannot disable user module.

One more way is to configure in drush configuration file as explained here

/**
 * Specify the modules to ignore when searching for command files (*.drush.inc)
 * inside a Drupal site.
 */
# $options['ignored-modules'] = array('module1', 'module2');
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.