I threw together a post-sync hook to enable my development modules after sql-sync -- something I've been planning on doing for 1+ years now, maybe? My plan was to put it in Drush extras, or maybe an example in drush.api.php, but then I wondered if folks might want this in Drush core, as a standard feature of core-rsync? Could be generally useful.

Usage:

$aliases['dev'] = array (
  'root' => '/srv/www/drupal',
  'uri' => 'site.com',
  'target-command-specific' => array(
    'sql-sync' => array(
      'enable' => array('devel', 'hacked'),
    ),
  ),
);

Here's the hook; it could easily be moved to sync.sql.inc, if desired.

function sync_extras_drush_help_alter(&$command) {
  if ($command['command'] == 'sql-sync') {
    $command['options']['enable'] = "Enable the specified modules in the target database after the sync operation has completed.";
  }
}

function drush_sync_extras_post_sql_sync($source = NULL, $destination = NULL) {
  $modules_to_enable = drush_get_option_list('enable');
  if (!empty($modules_to_enable)) {
    drush_log(dt("Enable !modules post-sql-sync", array('!modules' => implode(',', $modules_to_enable))), 'ok');
    drush_invoke_process($destination, 'pm-enable', $modules_to_enable, array('yes' => TRUE));
  }
}

Comments

moshe weitzman’s picture

Perhaps a small commandfile in /examples. And add some mentions from other docs.

I don't really want to add it into sql-sync itself as --sanitize is already a bit of an intrusion on the core functionality.

greg.1.anderson’s picture

Status: Active » Fixed

Added comments and committed as examples/sync_enable.drush.inc; added a drush topic to print it, and listed that topic in the 'topics' for `drush help sql-sync`.

mortona2k’s picture

Works great, thank you!

juampynr’s picture

Status: Fixed » Needs review
StatusFileSize
new2.41 KB

Here is a patch that adds an option to disable modules such as Secure Pages or Logging and Alerts.

juampynr’s picture

Oops, missed to update the last doc block. Here is an updated patch.

moshe weitzman’s picture

Assigned: Unassigned » greg.1.anderson
greg.1.anderson’s picture

Status: Needs review » Fixed

Useful addition; thanks.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.