Created
June 30, 2011 14:13
-
-
Save msonnabaum/1056313 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Command callback for sql-import. | |
*/ | |
function drush_sql_import($local_file) { | |
if (!drush_confirm(dt('Do you really want to drop all tables and import !dump_file?', array('!dump_file' => $local_file)))) { | |
return drush_user_abort(); | |
} | |
_drush_sql_drop(); | |
// Generate the import command | |
$import_command = _drush_sql_connect(); | |
switch (_drush_sql_get_scheme()) { | |
case 'mysql': | |
$import_command .= ' --silent'; | |
break; | |
case 'pgsql': | |
$import_command .= ' -q'; | |
break; | |
} | |
if (drush_shell_exec(sprintf('gzip -t "%s"', $local_file))) { | |
$import_exec = 'gunzip -c '; | |
} | |
else { | |
$import_exec = 'cat '; | |
} | |
$import_exec .= $local_file . '| ' . $import_command; | |
drush_op_system($import_exec); | |
if (drush_get_option('sanitize', FALSE)) { | |
drush_sql_sanitize(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment