Skip to content

Commit 6f2a237

Browse files
author
Paul Rogers
committed
fix(MigrateDumpCommand::mysqlDump): Drop "set -o pipefail" since it is unsupported by Travis.
1 parent 3bfa20d commit 6f2a237

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/Commands/MigrateDumpCommand.php

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,7 @@ private static function mysqlDump(array $db_config, string $schema_sql_path) : i
7171

7272
// Not including connection name in file since typically only one DB.
7373
// Excluding any hash or date suffix since only current is relevant.
74-
$command_prefix = 'set -o pipefail &&'
75-
. ' mysqldump --routines --skip-add-drop-table'
74+
$command_prefix = 'mysqldump --routines --skip-add-drop-table'
7675
. ' --skip-add-locks --skip-comments --skip-set-charset --tz-utc'
7776
. ' --host=' . escapeshellarg($db_config['host'])
7877
. ' --port=' . escapeshellarg($db_config['port'])
@@ -81,11 +80,18 @@ private static function mysqlDump(array $db_config, string $schema_sql_path) : i
8180
. ' ' . escapeshellarg($db_config['database']);
8281
passthru(
8382
$command_prefix
84-
. ' --no-data'
85-
// CONSIDER: Avoiding Bash/shell and Sed by doing replacement in PHP.
86-
. ' | sed -E "s/ AUTO_INCREMENT=[0-9]+ ?//g" > ' . escapeshellarg($schema_sql_path),
83+
. ' --result-file=' . escapeshellarg($schema_sql_path)
84+
. ' --no-data',
8785
$exit_code
8886
);
87+
$schema_sql = file_get_contents($schema_sql_path);
88+
if (false === $schema_sql) {
89+
return 1;
90+
}
91+
$schema_sql = preg_replace('/ AUTO_INCREMENT=[0-9]+ ?/iu', '', $schema_sql);
92+
if (false === file_put_contents($schema_sql_path, $schema_sql)) {
93+
return 1;
94+
}
8995

9096
// Include migration rows to avoid unnecessary reruns conflicting.
9197
if (0 === $exit_code) {

0 commit comments

Comments
 (0)