function drush_sql_post_sql_sync

6.x sync.sql.inc drush_sql_post_sql_sync($source = NULL, $destination = NULL)
4.x sync.sql.inc drush_sql_post_sql_sync($source = NULL, $destination = NULL)
5.x sync.sql.inc drush_sql_post_sql_sync($source = NULL, $destination = NULL)

Apply all post-sync operations that were registered in any pre-sync hook. Follow the pattern of this function to make your own post-sync hook. If changing the database, be sure to also include a pre-sync hook to notify the user of the change that will be made.

See also

drush_sql_pre_sql_sync().

File

commands/sql/sync.sql.inc, line 471

Code

function drush_sql_post_sql_sync($source = NULL, $destination = NULL) {
  $options = drush_get_context('post-sync-ops');
  if (!empty($options)) {
    // If 'deferred-sanitization' is set, then we collected the
    // sanitization operations -after- the database sync, which
    // means they were not confirmed up-front.  We will show the
    // operations here, but we will not offer an opportunity to
    // confirm unless --confirm-sanitizations is specified.
    if (drush_get_option('deferred-sanitization', FALSE) || drush_get_option('confirm-sanitizations', FALSE)) {
      if (!drush_get_context('DRUSH_SIMULATE')) {
        $messages = _drush_sql_get_post_sync_messages();
        if ($messages) {
          drush_print();
          drush_print($messages);
          if (drush_get_option('confirm-sanitizations', FALSE)) {
            if (!drush_confirm(dt('Do you really want to sanitize?'))) {
              // Do not abort or return FALSE; that would trigger a rollback.
              // Just skip the sanitizations and signal that all is ok.
              drush_log(dt('Sanitizations skipped.'), 'ok');
              return TRUE;
            }
          }
        }
      }
    }

    $destination_settings = drush_sitealias_get_record($destination);
    $sanitize_query = '';
    foreach ($options as $id => $data) {
      $sanitize_query .= $data['query'] . " ";
    }
    if ($sanitize_query) {
      if (!drush_get_context('DRUSH_SIMULATE')) {
        $result = drush_invoke_process($destination_settings, "sql-query", array($sanitize_query));
      }
      else {
        drush_print("Executing on $destination: $sanitize_query");
      }
    }
  }
}