D7: Export and Import Rules with Hook Update Deploy Tools

In Drupal 7, Features is one option for deploying Rules and changes to them.  Now there is another alternative.  As of version 7.x-1.10 of Hook Update Deploy Tools, the module adds the ability to use Drush to export an existing rule from a development server, commit it to version control, then deploy it to a production server using hook_update_N().

Of course being a method from HookUpdateDeployTools, it brings with it the standards of the module:

Module Release: Hook Update Deploy Tools

After working on several sites that were using hook_update_N() in install files to handle continuous site deployment by enabling modules, reverting features, updating menus and setting variables, we (CivicActions) built a handful of methods to more safely support that and issue better feedback when running `drush updb` or using update.php. 

Handy Drush DB commands

I use these commands to see drupal data, but not often enough to remember them when I need them.

drush sqlq --database=default "show tables"
drush sqlq --database=default "describe tablename"
drush sqlq --database=default "SELECT * FROM tablename"
drush sqlq --database=default "TRUNCATE TABLE tablename"

Get the number of rows in a table:

Drush sql-query output

Despite several tries, I have never had any luck using the native sql output formatting commands to work with drush

Install a Drupal Site and Profile

To install a Drupal site into a specific directory, this process works nicely with drush:

Drupal Code Style Review Git Commit Hooks

A nice feature for protecting a repository from badly formatted code that violates Drupal coding standards is to install Coder at the global drush level (not in a specific website) and then use Drupal Code Quality (dcq) to run that code review as a git commit hook that runs as you attempt to commit your code.

Installation instructions are here.

Drupal Code Style Review

Do review you Drupal code for style:
Install coder and enable enable it
drush dl coder
drush en coder

Then to run code style review on any module, cd into the module

drush dcs

Or on a specific file:

Installing drush

Here are some commands for installing drush from the command line

sudo apt-get install php-pear
pear channel-discover pear.drush.org
pear install drush/drush
drush version
pear upgrade drush/drush

But this is the new preferred way using Composer on *nix

# install composer
curl -sS https://getcomposer.org/installer | php -- --install-dir=bin --filename=composer
# You may need to mkdir ~/bin first if you don't have one.
Subscribe to RSS - Drush