Skip to content

Commit 029c282

Browse files
author
Paul Rogers
committed
chore(MigrateDumpCommand): Tolerate whitespace between comma and quote of migration rows.
1 parent 497db85 commit 029c282

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/Commands/MigrateDumpCommand.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,10 @@ private static function reorderMigrationRows(array $output) : array
6262
$reordered = [];
6363
$new_id = 1;
6464
foreach ($output as $line) {
65+
// Extract parts of "INSERT ... VALUES ([id],'[ver]',[batch])
66+
// where version begins with "YYYY_MM_DD_HHMMSS".
6567
$occurrences = preg_match(
66-
"/^(.*?VALUES\s*)\([0-9]+,'([0-9_]{17})(.*?),\s*[0-9]+\s*\)\s*;\s*$/iu",
68+
"/^(.*?VALUES\s*)\([0-9]+,\s*'([0-9_]{17})(.*?),\s*[0-9]+\s*\)\s*;\s*$/iu",
6769
$line,
6870
$m
6971
);
@@ -72,6 +74,8 @@ private static function reorderMigrationRows(array $output) : array
7274
'Only insert rows supported:' . PHP_EOL . var_export($line, 1)
7375
);
7476
}
77+
// Reassemble parts with new values and index by timestamp of
78+
// version string to sort.
7579
$reordered[$m[2]] = "$m[1]($new_id,'$m[2]$m[3],0);";
7680
$new_id += 1;
7781
}

0 commit comments

Comments
 (0)