From 18368ef34d3a5ed844a6c0645e035e665f7a39c8 Mon Sep 17 00:00:00 2001 From: lukasz-jarocki-sonarsource Date: Tue, 20 Aug 2024 11:42:12 +0200 Subject: [PATCH] SONAR-22521 fixed the issue where sometimes the upgrade warning text was not clear to the users --- .../server/platform/db/migration/version/DatabaseVersion.java | 2 ++ .../sonar/server/platform/DatabaseServerCompatibility.java | 4 +++- .../server/platform/DatabaseServerCompatibilityTest.java | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/DatabaseVersion.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/DatabaseVersion.java index 4359efb47b3..7472fa89545 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/DatabaseVersion.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/DatabaseVersion.java @@ -31,6 +31,8 @@ public class DatabaseVersion { * Note that the value can't be less than current LTA version. */ public static final long MIN_UPGRADE_VERSION = 6_802; + public static final String MIN_UPGRADE_VERSION_HUMAN_READABLE = "9.9"; + private final MigrationSteps migrationSteps; private final MigrationHistory migrationHistory; diff --git a/server/sonar-webserver-core/src/main/java/org/sonar/server/platform/DatabaseServerCompatibility.java b/server/sonar-webserver-core/src/main/java/org/sonar/server/platform/DatabaseServerCompatibility.java index 63ec4321e42..2d719224553 100644 --- a/server/sonar-webserver-core/src/main/java/org/sonar/server/platform/DatabaseServerCompatibility.java +++ b/server/sonar-webserver-core/src/main/java/org/sonar/server/platform/DatabaseServerCompatibility.java @@ -27,6 +27,7 @@ import org.sonar.api.utils.MessageException; import org.sonar.server.platform.db.migration.version.DatabaseVersion; import static org.sonar.server.log.ServerProcessLogging.STARTUP_LOGGER_NAME; +import static org.sonar.server.platform.db.migration.version.DatabaseVersion.MIN_UPGRADE_VERSION_HUMAN_READABLE; public class DatabaseServerCompatibility implements Startable { @@ -48,7 +49,8 @@ public class DatabaseServerCompatibility implements Startable { if (status == DatabaseVersion.Status.REQUIRES_UPGRADE) { Optional currentVersion = this.version.getVersion(); if (currentVersion.isPresent() && currentVersion.get() < DatabaseVersion.MIN_UPGRADE_VERSION) { - throw MessageException.of("The version of SonarQube is too old. Please upgrade to the Long-Term Active version first."); + throw MessageException.of("The version of SonarQube you are trying to upgrade from is too old. Please upgrade to the " + + MIN_UPGRADE_VERSION_HUMAN_READABLE + " Long-Term Active version first."); } String msg = "The database must be manually upgraded. Please backup the database and browse /setup. " diff --git a/server/sonar-webserver-core/src/test/java/org/sonar/server/platform/DatabaseServerCompatibilityTest.java b/server/sonar-webserver-core/src/test/java/org/sonar/server/platform/DatabaseServerCompatibilityTest.java index 022bc4716ee..ef892451ab6 100644 --- a/server/sonar-webserver-core/src/test/java/org/sonar/server/platform/DatabaseServerCompatibilityTest.java +++ b/server/sonar-webserver-core/src/test/java/org/sonar/server/platform/DatabaseServerCompatibilityTest.java @@ -56,7 +56,7 @@ public class DatabaseServerCompatibilityTest { var compatibility = new DatabaseServerCompatibility(version); assertThatThrownBy(compatibility::start) .isInstanceOf(MessageException.class) - .hasMessage("The version of SonarQube is too old. Please upgrade to the Long-Term Active version first."); + .hasMessage("The version of SonarQube you are trying to upgrade from is too old. Please upgrade to the 9.9 Long-Term Active version first."); } @Test -- 2.39.5