function drush_sql_sanitize

8.0.x sql.drush.inc drush_sql_sanitize()
6.x sql.drush.inc drush_sql_sanitize()
7.x sql.drush.inc drush_sql_sanitize()
4.x sql.drush.inc drush_sql_sanitize()
5.x sql.drush.inc drush_sql_sanitize()
master sql.drush.inc drush_sql_sanitize()

Command callback. Run's the sanitization operations on the current database.

File

commands/sql/sql.drush.inc, line 816
Drush sql commands

Code

function drush_sql_sanitize() {
  if (!drush_confirm(dt('Do you really want to sanitize the current database?'))) {
    return drush_user_abort();
  }
  drush_sql_bootstrap_further();
  drush_include(DRUSH_BASE_PATH . '/commands/sql', 'sync.sql');
  drush_command_invoke_all('drush_sql_sync_sanitize', 'default');
  $options = drush_get_context('post-sync-ops');
  if (!empty($options)) {
    if (!drush_get_context('DRUSH_SIMULATE')) {
      $messages = _drush_sql_get_post_sync_messages();
      if ($messages) {
        drush_print();
        drush_print($messages);
      }
    }
  }

  $sanitize_query = '';
  foreach ($options as $id => $data) {
    $sanitize_query .= $data['query'] . " ";
  }
  if ($sanitize_query) {
    if (!drush_get_context('DRUSH_SIMULATE')) {
      drush_sql_query($sanitize_query);
    }
    else {
      drush_print("Executing: $sanitize_query");
    }
  }
}