Skip to content

Commit a25c90b

Browse files
Fix upgrade filter skipping patch versions (#817) (#819)
FilterUpgrades used `FromVersion >= current` which excluded upgrades when the user was on a patch release (e.g., 2.4.1 skipped the 2.4.0-to-2.5.0 upgrade because 2.4.0 < 2.4.1). Changed to `ToVersion > current` so any upgrade the user hasn't reached is included. Adds regression test for the patch version scenario. Fixes #817 Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 19430a0 commit a25c90b

2 files changed

Lines changed: 18 additions & 1 deletion

File tree

Installer.Core/ScriptProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ protected static List<UpgradeInfo> FilterUpgrades(
152152

153153
return candidates
154154
.Where(x => x.FromVersion != null && x.ToVersion != null)
155-
.Where(x => x.FromVersion >= current)
155+
.Where(x => x.ToVersion > current)
156156
.Where(x => x.ToVersion <= target)
157157
.OrderBy(x => x.FromVersion)
158158
.ToList();

Installer.Tests/UpgradeOrderingTests.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,23 @@ public void DoesNotIncludeFutureUpgrades()
148148
Assert.DoesNotContain(upgrades, u => u.FolderName == "2.2.0-to-2.3.0");
149149
}
150150

151+
[Fact]
152+
public void PatchVersion_GetsUpgradeFromPriorMinor()
153+
{
154+
// Regression test for #817: user on v2.4.1 should still get the
155+
// 2.4.0-to-2.5.0 upgrade applied (patch version within range)
156+
using var dir = new TempDirectoryBuilder()
157+
.WithUpgrade("2.3.0", "2.4.0", "01_a.sql")
158+
.WithUpgrade("2.4.0", "2.5.0", "01_b.sql")
159+
.WithUpgrade("2.5.0", "2.6.0", "01_c.sql");
160+
161+
var upgrades = ScriptProvider.FromDirectory(dir.RootPath).GetApplicableUpgrades("2.4.1", "2.6.0");
162+
163+
Assert.Equal(2, upgrades.Count);
164+
Assert.Equal("2.4.0-to-2.5.0", upgrades[0].FolderName);
165+
Assert.Equal("2.5.0-to-2.6.0", upgrades[1].FolderName);
166+
}
167+
151168
[Fact]
152169
public void EmbeddedResources_FindsUpgradeFolders()
153170
{

0 commit comments

Comments
 (0)