We’ve seen how Drush Site Aliases can save any Drupal developer time in multiple environments. Now, we’ll discuss how Drush can also be used to maintain a site’s readiness. Part of the way a Drupal site works is by using a Module system that requires them to always be current. Using Drush it is possible to easily maintain all of the modules on a site. Drush makes it possible to install, enable, delete, or update modules.
While all of these commands are simple, installing and enabling modules require only the ability to type and read. To enable a module named MODULE type the following:
drush en MODULE
This will make an attempt to install the specified module and if successful, it will attempt to enable it. Given the situation that the module you are adding has more requirements, Drush will also ask if you would like to also install and enable the required modules.
Alternatively, if you simply want to install the module without enabling it, you can use the following command.
drush dl MODULE
This can also be accomplished using the drush en command by typing ‘n’ at the prompt to enable.
Updating modules is just as easy a task as installing or enabling. Prior to updating a module, it doesn’t hurt to read the release notes available for the desired module.
drush rln MODULE
It is always a good idea to read over release notes about an update to be sure that it will not be affected, as well as how it uses the module. It is also important to keep up to date on what changes have been made during security updates.
After updating modules it is always a good idea to check for database updates as well. Luckily, the smart developers of Drush thought ahead and made a command that does both of these tasks very well.
drush up MODULE
The above command will update both the specified module and any database updates available for that module along with it. After the update has completed, you should test the site and make sure anything that uses that module is still working as expected. It is good to note that when updating modules, if you are using version control, it would behove you to update one module at a time and do a commit between each update.
When it comes to deleting modules, there is an extra step that must be taken. In order to delete a module, all of the modules requiring that module must at least be disabled. Once that is done the module can then be uninstalled.
drush dis MODULE
drush pm-uninstall MODULE
In addition to module management tools, there are a number of commands available that can help gather information that may be desired from the admin panel. In the next blog, we’ll cover the basic reporting commands that are available with Drush.