Skip to content

Commit 8aae4e5

Browse files
authored
Add --extra option to sql:create, sql:drop, and site:install (#6249)
1 parent 03c59da commit 8aae4e5

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/Commands/core/SiteInstallCommands.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ public function __construct(
5555
#[CLI\Option(name: 'db-prefix', description: 'An optional table prefix to use for initial install.')]
5656
#[CLI\Option(name: 'db-su', description: 'Account to use when creating a new database. Must have Grant permission (mysql only). Optional.')]
5757
#[CLI\Option(name: 'db-su-pw', description: 'Password for the <info>db-su</info> account. Optional.')]
58+
#[CLI\Option(name: 'extra', description: 'Add custom options to the SQL connect string (e.g. --extra=--skip-column-names)')]
5859
#[CLI\Option(name: 'account-name', description: 'uid1 name.')]
5960
#[CLI\Option(name: 'account-pass', description: 'uid1 pass. Defaults to a randomly generated password. If desired, set a fixed password in drush.yml.')]
6061
#[CLI\Option(name: 'account-mail', description: 'uid1 email.')]
@@ -73,7 +74,7 @@ public function __construct(
7374
#[CLI\Usage(name: 'drush si core/recipes/standard', description: 'Install from the core Standard recipe.')]
7475
#[CLI\Bootstrap(level: DrupalBootLevels::ROOT)]
7576
#[CLI\Kernel(name: Kernels::INSTALLER)]
76-
public function install(array $recipeOrProfile, $options = ['db-url' => self::REQ, 'db-prefix' => self::REQ, 'db-su' => self::REQ, 'db-su-pw' => self::REQ, 'account-name' => 'admin', 'account-mail' => '[email protected]', 'site-mail' => '[email protected]', 'account-pass' => self::REQ, 'locale' => 'en', 'site-name' => 'Drush Site-Install', 'site-pass' => self::REQ, 'sites-subdir' => self::REQ, 'config-dir' => self::REQ, 'existing-config' => false]): void
77+
public function install(array $recipeOrProfile, $options = ['db-url' => self::REQ, 'db-prefix' => self::REQ, 'db-su' => self::REQ, 'db-su-pw' => self::REQ, 'extra' => self::REQ, 'account-name' => 'admin', 'account-mail' => '[email protected]', 'site-mail' => '[email protected]', 'account-pass' => self::REQ, 'locale' => 'en', 'site-name' => 'Drush Site-Install', 'site-pass' => self::REQ, 'sites-subdir' => self::REQ, 'config-dir' => self::REQ, 'existing-config' => false]): void
7778
{
7879
$additional = $recipeOrProfile;
7980
$recipeOrProfile = array_shift($additional) ?: '';

src/Commands/sql/SqlCommands.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,13 @@ public function connect($options = ['extra' => self::REQ]): string
8181
#[CLI\Command(name: self::CREATE, aliases: ['sql-create'])]
8282
#[CLI\Option(name: 'db-su', description: 'Account to use when creating a new database.')]
8383
#[CLI\Option(name: 'db-su-pw', description: 'Password for the db-su account.')]
84+
#[CLI\Option(name: 'extra', description: 'Add custom options to the connect string (e.g. --extra=--skip-column-names)')]
8485
#[CLI\Usage(name: 'drush sql:create', description: 'Create the database for the current site.')]
8586
#[CLI\Usage(name: 'drush @site.test sql:create', description: 'Create the database as specified for @site.test.')]
8687
#[CLI\Usage(name: 'drush sql:create --db-su=root --db-su-pw=rootpassword --db-url="mysql://drupal_db_user:[email protected]/drupal_db"', description: 'Create the database as specified in the db-url option.')]
8788
#[CLI\Bootstrap(level: DrupalBootLevels::MAX, max_level: DrupalBootLevels::CONFIGURATION)]
8889
#[CLI\OptionsetSql]
89-
public function createDb($options = ['db-su' => self::REQ, 'db-su-pw' => self::REQ]): void
90+
public function createDb($options = ['db-su' => self::REQ, 'db-su-pw' => self::REQ, 'extra' => self::REQ]): void
9091
{
9192
$sql = SqlBase::create($options);
9293
$db_spec = $sql->getDbSpec();
@@ -106,9 +107,10 @@ public function createDb($options = ['db-su' => self::REQ, 'db-su-pw' => self::R
106107
*/
107108
#[CLI\Command(name: self::DROP, aliases: ['sql-drop'])]
108109
#[CLI\Bootstrap(level: DrupalBootLevels::MAX, max_level: DrupalBootLevels::CONFIGURATION)]
110+
#[CLI\Option(name: 'extra', description: 'Add custom options to the connect string (e.g. --extra=--skip-column-names)')]
109111
#[CLI\OptionsetSql]
110112
#[CLI\Topics(topics: [DocsCommands::POLICY])]
111-
public function drop($options = []): void
113+
public function drop($options = ['extra' => self::REQ]): void
112114
{
113115
$sql = SqlBase::create($options);
114116
$db_spec = $sql->getDbSpec();

0 commit comments

Comments
 (0)