Browse Source
Merge pull request #15926 from thingsboard/refactor/lts-version-is-in-range
Move LTS version range check into LtsVersion
lts-4.2
Viacheslav Klimov
3 days ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with
9 additions and
3 deletions
-
application/src/main/java/org/thingsboard/server/service/install/lts/LtsMigrationService.java
-
application/src/main/java/org/thingsboard/server/service/install/lts/LtsVersion.java
|
|
|
@ -126,9 +126,7 @@ public class LtsMigrationService { |
|
|
|
// so a cross-family upgrade is fully handled by the target-family migrations.
|
|
|
|
// Excluding the dormant older-family beans avoids double-processing.
|
|
|
|
static boolean isInRangeForTargetFamily(LtsVersion version, LtsVersion from, LtsVersion to) { |
|
|
|
return version.sameFamily(to) |
|
|
|
&& version.compareTo(from) > 0 |
|
|
|
&& version.compareTo(to) <= 0; |
|
|
|
return version.sameFamily(to) && version.isInRange(from, to); |
|
|
|
} |
|
|
|
|
|
|
|
private void runSchemaUpdate(String version) { |
|
|
|
|
|
|
|
@ -37,6 +37,14 @@ public record LtsVersion(int major, int minor, int maintenance, int patch) imple |
|
|
|
return major == other.major && minor == other.minor; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Half-open range check: {@code from < this <= to}. The lower bound is exclusive (a source already at |
|
|
|
* {@code from} has applied that version) and the upper bound inclusive (the target version's own migration runs). |
|
|
|
*/ |
|
|
|
public boolean isInRange(LtsVersion from, LtsVersion to) { |
|
|
|
return compareTo(from) > 0 && compareTo(to) <= 0; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public int compareTo(LtsVersion o) { |
|
|
|
int c = Integer.compare(major, o.major); |
|
|
|
|