summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--commands/core/core.drush.inc6
-rw-r--r--commands/core/site_install.drush.inc3
-rw-r--r--commands/sql/sql.drush.inc17
-rw-r--r--commands/sql/sync.sql.inc13
-rw-r--r--tests/COVERAGE.txt5
5 files changed, 28 insertions, 16 deletions
diff --git a/commands/core/core.drush.inc b/commands/core/core.drush.inc
index ec1f3b8..aa4f24b 100644
--- a/commands/core/core.drush.inc
+++ b/commands/core/core.drush.inc
@@ -162,11 +162,13 @@ function core_drush_command() {
'key=value...' => 'any additional settings you wish to pass to the profile. Only support on D7. The key is in the form [form name].[parameter name].',
),
'options' => array(
- 'db-url' => 'A Drupal 5/6 style database URL. Only required for initial install - not re-install.',
- 'db-prefix' => 'An optional table prefix to use for initial install.',
'account-name' => 'uid1 name. defaults to admin',
'account-pass' => 'uid1 pass. defaults to admin',
'account-mail' => 'uid1 email. defaults to admin@example.com',
+ 'db-url' => 'A Drupal 5/6 style database URL. Only required for initial install - not re-install.',
+ 'db-prefix' => 'An optional table prefix to use for initial install.',
+ 'db-su' => 'Account to use when creating a new database. Optional.',
+ 'db-su-pw' => 'Password for the "db-su" account. Optional.',
'locale' => 'A short language code. Sets the default site language. Language files must already be present. You may use download command to get them.',
'clean-url'=> 'Defaults to 1',
'site-name' => 'Defaults to Site-Install',
diff --git a/commands/core/site_install.drush.inc b/commands/core/site_install.drush.inc
index a382d2f..a2577d2 100644
--- a/commands/core/site_install.drush.inc
+++ b/commands/core/site_install.drush.inc
@@ -97,7 +97,8 @@ function drush_core_pre_site_install() {
// are about to DROP. @see _drush_sql_get_credentials().
$create_db_spec = $db_spec;
unset($create_db_spec['database']);
- if (!_drush_sql_query($sql, $create_db_spec)) {
+ $create_db_su = drush_sql_su($create_db_spec);
+ if (!_drush_sql_query($sql, $create_db_su)) {
// If we could not drop the database, try instead to drop all
// of the tables in the database (presuming it exists...).
// If we cannot do either operation, then fail with an error.
diff --git a/commands/sql/sql.drush.inc b/commands/sql/sql.drush.inc
index 11644a9..5ce9913 100644
--- a/commands/sql/sql.drush.inc
+++ b/commands/sql/sql.drush.inc
@@ -814,6 +814,23 @@ function drush_sql_show_tables_pgsql() {
}
/*
+ * Build DB connection array with superuser credentials if provided.
+ */
+function drush_sql_su($db_spec) {
+ $create_db_target = $db_spec;
+ $create_db_target['database'] = '';
+ $db_superuser = drush_get_option(array('db-su', 'target-db-su'));
+ if (isset($db_superuser)) {
+ $create_db_target['username'] = $db_superuser;
+ }
+ $db_su_pw = drush_get_option(array('db-su-pw', 'target-db-su-pw'));
+ if (isset($db_su_pw)) {
+ $create_db_target['password'] = $db_su_pw;
+ }
+ return $create_db_target;
+}
+
+/*
* Build a SQL string for dropping and creating a database.
*
* @param array $db_spec
diff --git a/commands/sql/sync.sql.inc b/commands/sql/sync.sql.inc
index ce0e444..b1d23a5 100644
--- a/commands/sql/sync.sql.inc
+++ b/commands/sql/sync.sql.inc
@@ -378,17 +378,8 @@ function drush_sql_sync($source = NULL, $destination = NULL) {
$pre_import_commands = '';
$create_db = drush_get_option('create-db');
if (isset($create_db)) {
- $create_db_target = $target_db_url;
- $create_db_target['database'] = '';
- $db_superuser = drush_get_option(array('db-su', 'target-db-su'));
- if (isset($db_superuser)) {
- $create_db_target['username'] = $db_superuser;
- }
- $db_su_pw = drush_get_option(array('db-su-pw', 'target-db-su-pw'));
- if (isset($db_su_pw)) {
- $create_db_target['password'] = $db_su_pw;
- }
- $db_su_connect = _drush_sql_connect($create_db_target);
+ $create_db_su = drush_sql_su($target_db_url);
+ $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);
}
diff --git a/tests/COVERAGE.txt b/tests/COVERAGE.txt
index 9c8b869..0739c9d 100644
--- a/tests/COVERAGE.txt
+++ b/tests/COVERAGE.txt
@@ -23,7 +23,8 @@ sql-drop:
updatedb: GOOD. Implicitly tested siteUpgradeTest.
-archive-dump
+archive-dump: GOOD
+archive-restore:
help
version: Good. Implicit by testStandaloneScript()
self-update
@@ -69,4 +70,4 @@ ROOT
-------------
drush
drush.php
-drush.bat \ No newline at end of file
+drush.bat