Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions src/Commands/MigrateDumpCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,14 +142,15 @@ public static function reorderMigrationRows(array $output) : array
*/
private static function mysqlSchemaDump(array $db_config, string $schema_sql_path) : int
{
// TODO: Suppress warning about insecure password.
// CONSIDER: Intercepting stdout and stderr and converting to colorized
// console output with `$this->info` and `->error`.
passthru(
static::mysqlCommandPrefix($db_config)
'bash -c "'
. static::mysqlCommandPrefix($db_config)
. ' --result-file=' . escapeshellarg($schema_sql_path)
. ' --no-data'
. ' --routines',
. ' --routines'
. ' 2> >(grep -v \'Using a password on the command line interface can be insecure.\')"',
$exit_code
);

Expand All @@ -170,13 +171,15 @@ private static function mysqlSchemaDump(array $db_config, string $schema_sql_pat

// Include migration rows to avoid unnecessary reruns conflicting.
exec(
static::mysqlCommandPrefix($db_config)
'bash -c "'
. static::mysqlCommandPrefix($db_config)
. ' ' . ($db_config['prefix'] ?? '') . 'migrations'
. ' --no-create-info'
. ' --skip-extended-insert'
. ' --skip-routines'
. ' --single-transaction'
. ' --compact',
. ' --compact'
. ' 2> >(grep -v \'Using a password on the command line interface can be insecure.\')"',
$output,
$exit_code
);
Expand Down Expand Up @@ -207,11 +210,13 @@ private static function mysqlSchemaDump(array $db_config, string $schema_sql_pat
private static function mysqlDataDump(array $db_config, string $data_sql_path) : int
{
passthru(
static::mysqlCommandPrefix($db_config)
'bash -c "'
. static::mysqlCommandPrefix($db_config)
. ' --result-file=' . escapeshellarg($data_sql_path)
. ' --no-create-info --skip-routines --skip-triggers'
. ' --ignore-table=' . escapeshellarg($db_config['database'] . '.' . ($db_config['prefix'] ?? '') . 'migrations')
. ' --single-transaction', // Avoid disruptive locks.
. ' --single-transaction' // Avoid disruptive locks.
. ' 2> >(grep -v \'Using a password on the command line interface can be insecure.\')"',
$exit_code
);

Expand Down
6 changes: 4 additions & 2 deletions src/Commands/MigrateLoadCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,15 @@ private static function mysqlLoad(string $path, array $db_config, int $verbosity
// CONSIDER: Making input file an option which can override default.
// CONSIDER: Avoiding shell specifics like `cat` and piping using
// `file_get_contents` or similar.
$command = 'cat ' . escapeshellarg($path)
$command = 'bash -c "'
. 'cat ' . escapeshellarg($path)
. ' | mysql --no-beep'
. ' --host=' . escapeshellarg($db_config['host'])
. ' --port=' . escapeshellarg($db_config['port'] ?? 3306)
. ' --user=' . escapeshellarg($db_config['username'])
. ' --password=' . escapeshellarg($db_config['password'])
. ' --database=' . escapeshellarg($db_config['database']);
. ' --database=' . escapeshellarg($db_config['database'])
. ' 2> >(grep -v \'Using a password on the command line interface can be insecure.\')"';
switch($verbosity) {
case OutputInterface::VERBOSITY_QUIET:
$command .= ' -q';
Expand Down