Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Add tests
  • Loading branch information
dereuromark committed Aug 3, 2025
commit 06e465ac028bfdf0e403d7fab6adcd9dd51f2daf
5 changes: 1 addition & 4 deletions src/Migration/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -553,20 +553,17 @@ public function rollbackByCount(int $count, bool $force = false, bool $fake = fa
// note that the version log are also indexed by name with the proper ascending order according to the version order
$executedVersions = $this->getEnvironment()->getVersionLog();

$target = null;
$total = count($executedVersions);
$pos = 0;
while ($pos < $count && $pos < $total) {
array_pop($executedVersions);
$pos++;
}

// After popping, get the last remaining version as the target
if (!empty($executedVersions)) {
if ($executedVersions) {
$last = end($executedVersions);
$target = $last['version'];
} else {
// If no versions remain, rollback everything
$target = 0;
}

Expand Down
Loading