Skip to content

Commit c6f10f3

Browse files
Merge pull request #51869 from nextcloud/backport/51866/stable31
[stable31] fix: use proper migration sorting when checking if a migration needs to be executed
2 parents 25a0f4b + 28c6375 commit c6f10f3

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/private/DB/MigrationService.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,9 +199,9 @@ protected function sortMigrations(string $a, string $b): int {
199199
if ($versionA !== $versionB) {
200200
return ($versionA < $versionB) ? -1 : 1;
201201
}
202-
return ($matchA[2] < $matchB[2]) ? -1 : 1;
202+
return strnatcmp($matchA[2], $matchB[2]);
203203
}
204-
return (basename($a) < basename($b)) ? -1 : 1;
204+
return strnatcmp(basename($a), basename($b));
205205
}
206206

207207
/**
@@ -250,7 +250,7 @@ private function getMigrationsToExecute($to) {
250250

251251
$toBeExecuted = [];
252252
foreach ($availableMigrations as $v) {
253-
if ($to !== 'latest' && $v > $to) {
253+
if ($to !== 'latest' && ($this->sortMigrations($v, $to) > 0)) {
254254
continue;
255255
}
256256
if ($this->shallBeExecuted($v, $knownMigrations)) {

0 commit comments

Comments
 (0)