diff --git a/commands/sql/sync.sql.inc b/commands/sql/sync.sql.inc index 56bcc25..c58a5e1 100644 --- a/commands/sql/sync.sql.inc +++ b/commands/sql/sync.sql.inc @@ -289,7 +289,13 @@ function drush_sql_sync($source = NULL, $destination = NULL) { drush_print(); $txt_source = (isset($source_db_url['remote-host']) ? $source_db_url['remote-host'] . '/' : '') . $source_db_url['database']; $txt_destination = (isset($target_db_url['remote-host']) ? $target_db_url['remote-host'] . '/' : '') . $target_db_url['database']; - drush_print(dt("You will destroy data in !target and replace with data from !source.", array('!source' => $txt_source, '!target' => $txt_destination))); + $create_db = drush_sitealias_get_option($destination_settings, 'create-db'); + if (isset($create_db) && ($create_db == 'true')) { + drush_print(dt("You will destroy all data in !target and replace with data from !source.", array('!source' => $txt_source, '!target' => $txt_destination))); + } + else { + drush_print(dt("All data in tables from !target will be replaced with data from tables with identical names from !source. Orphan tables will remain in the target database. If this is not what you intended, consider cancelling this operation and execute it again with the '--create-db' option.", array('!source' => $txt_source, '!target' => $txt_destination))); + } } // If any sanitization operations are to be done, then get the @@ -394,7 +400,9 @@ function drush_sql_sync($source = NULL, $destination = NULL) { $create_db_su = drush_sql_su($target_db_url, $destination_settings); $db_su_connect = _drush_sql_connect($create_db_su); $pre_import_sql = drush_sql_build_createdb_sql($target_db_url); - $pre_import_commands = sprintf('echo "%s" | %s; ', $pre_import_sql, $db_su_connect); + // Using "mysql -e' instead of "echo 'command' | mysql" below + // for Windows compability reasons. See http://drupal.org/node/1957020. + $pre_import_commands = sprintf('%s -e "%s" && ', $db_su_connect, $pre_import_sql); } // Generate the import command