Using drush to re-install modules

[image from: k::snyder]

Sometimes the trickiest part of Drupal module development is the install. Setting up database schema etc., and even more fiddly creating custom content types with custom fields on install.

Anyway here are some drush commands that have been getting a lot of love from me.

drush dre -y MY_MODULE  

Is my basic. It requires the devel module and will pm-disable, pm-uninstall and finally pm-enable all with the -y option which says 'answer yes to all questions'.

But you may ask, how do I dre a package of inter-dependent modules for a more complex install. I've split a module large into parts (client facing, admin and core for example) and so re-installing the whole thing is a pain as

drush dre MY_CORE_MODULE  

doesn't work because MY_CORE_MODULE dependency for the other 2. At that point I've been using:

drush pml --package="MY PACKAGE" --pipe | xargs drush dis -y  
drush pml --package="MY PACKAGE" --pipe | xargs drush pm-uninstall -y  
drush pml --package="MY PACKAGE" --pipe | xargs drush en -y  

Not terribly elegant I'll admit, but gets the job done, and it's something you could put in a bash script if you need it repeatedly.