Simplify your development workflow with Drush and scripts

We would like to share a tool with you that has helped speed up our development process as a team.

If you work on Drupal sites with a team of other developers you will know the problem: You pulled code and all of a sudden you get strange errors. Eventually you find out you need to run update.php or revert a certain Feature or clear the cache. Maybe you even got into the habit of just doing all of that after each pull and it takes up some valuable time that you need elsewhere. To avoid these problems we introduced shell scripts a while ago. Within just a few months they have evolved into a multi-file system with subscripts, but I want to share them in their simplest form.

Here's a few examples of what you can do in a script, combined with the powers of Drush:

  • Enable and disable modules or themes
  • Revert your Features
  • Clear your caches
  • Run database updates
  • Delete content types and fields
  • Index content for solr
  • Whatever else Drush can do
  • Output some audio when the script is finished!

Our scripts live in sites/all/scripts. Drupal by default disallows access to .sh files so there's nothing we need to do there to keep our files private.

[gist:5848905]

Because the script tells us when it's finished, we can just go do something else while it runs.

We also use an installation script so everyone on the team can get started quickly. Basically, we expect to be able to set up the project from scratch at any time by just running install.sh and update.sh:

[gist:5848790]

This is really helpful if anyone wants to test their development with a fresh database, but using the current code base. It helps avoid problems that occur if someone forgot to export some setting in a Feature.

What do you think about our scripts? Does your team use something like this during development?