Skip to content

Commit 79d7ccf

Browse files
authored
Merge pull request #66 from dlubitz/feature/configurable-db-command
Add configuration to set the local database command
2 parents b96bd1d + fe7f5d6 commit 79d7ccf

File tree

5 files changed

+22
-8
lines changed

5 files changed

+22
-8
lines changed

Classes/Command/AbstractCommandController.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ abstract class AbstractCommandController extends CommandController
4444
*/
4545
protected $flowCommand;
4646

47+
/**
48+
* @var string
49+
* @Flow\InjectConfiguration("databaseCommand")
50+
*/
51+
protected $databaseCommand;
52+
4753
/**
4854
* @Flow\Inject
4955
* @var ConfigurationService

Classes/Command/CloneCommandController.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,8 @@ protected function cloneRemoteHost(
260260
(int)$this->databaseConfiguration['port'],
261261
$this->databaseConfiguration['user'],
262262
$this->databaseConfiguration['password'],
263-
$this->databaseConfiguration['dbname']
263+
$this->databaseConfiguration['dbname'],
264+
$this->databaseCommand
264265
)
265266
]
266267
);
@@ -298,7 +299,8 @@ protected function cloneRemoteHost(
298299
(int)$this->databaseConfiguration['port'],
299300
$this->databaseConfiguration['user'],
300301
$this->databaseConfiguration['password'],
301-
$this->databaseConfiguration['dbname']
302+
$this->databaseConfiguration['dbname'],
303+
$this->databaseCommand
302304
)
303305
]
304306
);
@@ -327,7 +329,8 @@ protected function cloneRemoteHost(
327329
(int)$this->databaseConfiguration['port'],
328330
$this->databaseConfiguration['user'],
329331
$this->databaseConfiguration['password'],
330-
$this->databaseConfiguration['dbname']
332+
$this->databaseConfiguration['dbname'],
333+
$this->databaseCommand
331334
)
332335
]
333336
);

Classes/Command/StashCommandController.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,8 @@ protected function restoreStashEntry($source, $name, $force = false, $preserve =
340340
(int)$this->databaseConfiguration['port'],
341341
$this->databaseConfiguration['user'],
342342
$this->databaseConfiguration['password'],
343-
$this->databaseConfiguration['dbname']
343+
$this->databaseConfiguration['dbname'],
344+
$this->databaseCommand
344345
)
345346
]
346347
);
@@ -362,7 +363,8 @@ protected function restoreStashEntry($source, $name, $force = false, $preserve =
362363
(int)$this->databaseConfiguration['port'],
363364
$this->databaseConfiguration['user'],
364365
$this->databaseConfiguration['password'],
365-
$this->databaseConfiguration['dbname']
366+
$this->databaseConfiguration['dbname'],
367+
$this->databaseCommand
366368
) . ' < ' . $source . '/database.sql'
367369
);
368370

Classes/DBAL/SimpleDBAL.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ class SimpleDBAL
2020
* @param string $database
2121
* @return string
2222
*/
23-
public function buildCmd(string $driver, ?string $host, int $port, string $username, string $password, string $database): string
23+
public function buildCmd(string $driver, ?string $host, int $port, string $username, string $password, string $database, ?string $databaseCommand = null): string
2424
{
2525
if ($driver === 'pdo_mysql') {
26-
return sprintf('mysql --host=%s --port=%s --user=%s --password=%s %s', escapeshellarg($host), escapeshellarg($port), escapeshellarg($username), escapeshellarg($password), escapeshellarg($database));
26+
return sprintf(($databaseCommand ?: 'mysql') . ' --host=%s --port=%s --user=%s --password=%s %s', escapeshellarg($host), escapeshellarg($port), escapeshellarg($username), escapeshellarg($password), escapeshellarg($database));
2727
} else if ($driver === 'pdo_pgsql') {
28-
return sprintf('PGOPTIONS=--client-min-messages=warning PGPASSWORD=%s psql --quiet --host=%s --port=%s --username=%s --dbname=%s', escapeshellarg($password), escapeshellarg($host), escapeshellarg($port), escapeshellarg($username), escapeshellarg($database));
28+
return sprintf('PGOPTIONS=--client-min-messages=warning PGPASSWORD=%s ' . ($databaseCommand ?: 'psql') . ' --quiet --host=%s --port=%s --username=%s --dbname=%s', escapeshellarg($password), escapeshellarg($host), escapeshellarg($port), escapeshellarg($username), escapeshellarg($database));
2929
}
3030
}
3131

Configuration/Settings.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ Sitegeist:
33

44
# the local flow command
55
flowCommand: './flow'
6+
# the custom local database command, defaults to mysql or psql
7+
# databaseCommand: ~
8+
69
# # preset which is used by the clone:default command
710
# defaultPreset: 'master'
811
# clonePresets: []

0 commit comments

Comments
 (0)