Skip to content

Commit 89c12c4

Browse files
author
Paul Rogers
committed
fix(MigrateDumpCommand): Correct reordering with Pg_dump.
1 parent 05f0596 commit 89c12c4

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/Commands/MigrateDumpCommand.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,14 +236,23 @@ private static function pgsqlDump(array $db_config, string $schema_sql_path) : i
236236

237237
// Include migration rows to avoid unnecessary reruns conflicting.
238238
exec(
239-
$command_prefix . ' --table=migrations --data-only --inserts',
239+
$command_prefix . ' --table=migrations --data-only --inserts --no-comments',
240240
$output,
241241
$exit_code
242242
);
243243
if (0 !== $exit_code) {
244244
return $exit_code;
245245
}
246246

247+
// Cut "SET" statements and workaround `--no-comments` not always working.
248+
$output = array_filter(
249+
$output,
250+
function ($line) {
251+
return 0 === preg_match('/^\s*(--|SELECT\s|SET\s)/iu', $line)
252+
&& 0 < mb_strlen($line);
253+
}
254+
);
255+
247256
$output = self::reorderMigrationRows($output);
248257

249258
file_put_contents(

0 commit comments

Comments
 (0)