From ea2bcfd9b0137fcff0e88404e9fa2cadbbfda6c6 Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Wed, 14 Mar 2012 06:27:15 +0100 Subject: [PATCH] Do not log 'require upgrade' on fresh installs --- .../java/org/sonar/core/persistence/DatabaseVersion.java | 6 ++++-- .../org/sonar/core/persistence/DatabaseVersionTest.java | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/sonar-core/src/main/java/org/sonar/core/persistence/DatabaseVersion.java b/sonar-core/src/main/java/org/sonar/core/persistence/DatabaseVersion.java index 942d41eb61f..1d3b431a4e6 100644 --- a/sonar-core/src/main/java/org/sonar/core/persistence/DatabaseVersion.java +++ b/sonar-core/src/main/java/org/sonar/core/persistence/DatabaseVersion.java @@ -35,7 +35,7 @@ public class DatabaseVersion implements BatchComponent, ServerComponent { public static final int LAST_VERSION = 263; public static enum Status { - UP_TO_DATE, REQUIRES_UPGRADE, REQUIRES_DOWNGRADE + UP_TO_DATE, REQUIRES_UPGRADE, REQUIRES_DOWNGRADE, FRESH_INSTALL } private MyBatis mybatis; @@ -69,12 +69,14 @@ public class DatabaseVersion implements BatchComponent, ServerComponent { @VisibleForTesting static Status getStatus(Integer currentVersion, int lastVersion) { - Status status = Status.REQUIRES_UPGRADE; + Status status = Status.FRESH_INSTALL; if (currentVersion != null) { if (currentVersion == lastVersion) { status = Status.UP_TO_DATE; } else if (currentVersion > lastVersion) { status = Status.REQUIRES_DOWNGRADE; + } else { + status = Status.REQUIRES_UPGRADE; } } return status; diff --git a/sonar-core/src/test/java/org/sonar/core/persistence/DatabaseVersionTest.java b/sonar-core/src/test/java/org/sonar/core/persistence/DatabaseVersionTest.java index 03d6033df55..9dbee6dbe21 100644 --- a/sonar-core/src/test/java/org/sonar/core/persistence/DatabaseVersionTest.java +++ b/sonar-core/src/test/java/org/sonar/core/persistence/DatabaseVersionTest.java @@ -47,7 +47,7 @@ public class DatabaseVersionTest extends DaoTestCase { @Test public void getStatus() { - assertThat(DatabaseVersion.getStatus(null, 150), is(DatabaseVersion.Status.REQUIRES_UPGRADE)); + assertThat(DatabaseVersion.getStatus(null, 150), is(DatabaseVersion.Status.FRESH_INSTALL)); assertThat(DatabaseVersion.getStatus(123, 150), is(DatabaseVersion.Status.REQUIRES_UPGRADE)); assertThat(DatabaseVersion.getStatus(150, 150), is(DatabaseVersion.Status.UP_TO_DATE)); assertThat(DatabaseVersion.getStatus(200, 150), is(DatabaseVersion.Status.REQUIRES_DOWNGRADE)); -- 2.39.5