diff options
author | Sébastien Lesaint <sebastien.lesaint@sonarsource.com> | 2016-12-16 09:12:19 +0100 |
---|---|---|
committer | Sébastien Lesaint <sebastien.lesaint@sonarsource.com> | 2016-12-16 14:35:28 +0100 |
commit | 1c34d6ef83b6e9dbfada259c3111acbad3c1ff03 (patch) | |
tree | 1d1c8b9133084a3cb884aada25089436054e22ac | |
parent | 90d681b83f6399929da48aad426e20f857ff60f3 (diff) | |
download | sonarqube-1c34d6ef83b6e9dbfada259c3111acbad3c1ff03.tar.gz sonarqube-1c34d6ef83b6e9dbfada259c3111acbad3c1ff03.zip |
SONAR-8445 move DatabaseVersion to sonar-db-migration
21 files changed, 112 insertions, 84 deletions
diff --git a/server/sonar-ce/src/main/java/org/sonar/ce/container/ComputeEngineContainerImpl.java b/server/sonar-ce/src/main/java/org/sonar/ce/container/ComputeEngineContainerImpl.java index 8ca295e95aa..0b13b6fc832 100644 --- a/server/sonar-ce/src/main/java/org/sonar/ce/container/ComputeEngineContainerImpl.java +++ b/server/sonar-ce/src/main/java/org/sonar/ce/container/ComputeEngineContainerImpl.java @@ -63,7 +63,7 @@ import org.sonar.db.DatabaseChecker; import org.sonar.db.DbClient; import org.sonar.db.DefaultDatabase; import org.sonar.db.purge.PurgeProfiler; -import org.sonar.db.version.DatabaseVersion; +import org.sonar.server.platform.db.migration.version.DatabaseVersion; import org.sonar.process.Props; import org.sonar.process.logging.LogbackHelper; import org.sonar.server.component.ComponentCleanerService; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/charset/ColumnDef.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/charset/ColumnDef.java index da7708cbbfd..3e40e7ea011 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/charset/ColumnDef.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/charset/ColumnDef.java @@ -23,7 +23,7 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.util.Locale; import javax.annotation.concurrent.Immutable; -import org.sonar.db.version.DatabaseVersion; +import org.sonar.db.version.SqTables; /** * Result of standard SQL command "select * from INFORMATION_SCHEMA" (columns listed in {@link #SELECT_COLUMNS}). @@ -81,7 +81,7 @@ public class ColumnDef { public boolean isInSonarQubeTable() { String tableName = table.toLowerCase(Locale.ENGLISH); - return DatabaseVersion.TABLES.contains(tableName) || DatabaseVersion.OLD_DROPPED_TABLES.contains(tableName); + return SqTables.TABLES.contains(tableName) || SqTables.OLD_DROPPED_TABLES.contains(tableName); } public enum ColumnDefRowConverter implements SqlExecutor.RowConverter<ColumnDef> { diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/history/MigrationHistoryImpl.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/history/MigrationHistoryImpl.java index 8e08992f19c..b1fc36497ad 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/history/MigrationHistoryImpl.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/history/MigrationHistoryImpl.java @@ -30,11 +30,12 @@ import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.schemamigration.SchemaMigrationMapper; import org.sonar.server.platform.db.migration.step.RegisteredMigrationStep; +import org.sonar.server.platform.db.migration.version.DatabaseVersion; import static com.google.common.base.Preconditions.checkState; /** - * TODO make {@link org.sonar.db.version.DatabaseVersion} use this class + * TODO make {@link DatabaseVersion} use this class */ public class MigrationHistoryImpl implements MigrationHistory { private final DbClient dbClient; 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 new file mode 100644 index 00000000000..cfe8a89f23e --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/DatabaseVersion.java @@ -0,0 +1,84 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.platform.db.migration.version; + +import com.google.common.annotations.VisibleForTesting; +import java.util.Collections; +import java.util.List; +import javax.annotation.Nullable; +import org.sonar.db.DatabaseUtils; +import org.sonar.db.DbClient; +import org.sonar.db.DbSession; + +public class DatabaseVersion { + + public static final int LAST_VERSION = 1_502; + + /** + * The minimum supported version which can be upgraded. Lower + * versions must be previously upgraded to LTS version. + * Note that the value can't be less than current LTS version. + */ + public static final int MIN_UPGRADE_VERSION = 1_152; + + private final DbClient dbClient; + + public DatabaseVersion(DbClient dbClient) { + this.dbClient = dbClient; + } + + @VisibleForTesting + static Status getStatus(@Nullable Integer currentVersion, int lastVersion) { + 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; + } + + public Status getStatus() { + return getStatus(getVersion(), LAST_VERSION); + } + + public Integer getVersion() { + try (DbSession dbSession = dbClient.openSession(false)) { + if (!DatabaseUtils.tableExists("SCHEMA_MIGRATIONS", dbSession.getConnection())) { + return null; + } + + List<Integer> versions = dbClient.schemaMigrationDao().selectVersions(dbSession); + if (!versions.isEmpty()) { + Collections.sort(versions); + return versions.get(versions.size() - 1); + } + return null; + } + } + + public enum Status { + UP_TO_DATE, REQUIRES_UPGRADE, REQUIRES_DOWNGRADE, FRESH_INSTALL + } +} diff --git a/sonar-db/src/test/java/org/sonar/db/version/DatabaseVersionTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/DatabaseVersionTest.java index cb1e3219ce9..ff5d406f258 100644 --- a/sonar-db/src/test/java/org/sonar/db/version/DatabaseVersionTest.java +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/DatabaseVersionTest.java @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -package org.sonar.db.version; +package org.sonar.server.platform.db.migration.version; import org.junit.Rule; import org.junit.Test; diff --git a/server/sonar-server/src/main/java/org/sonar/server/platform/BackendCleanup.java b/server/sonar-server/src/main/java/org/sonar/server/platform/BackendCleanup.java index bb5ba51b32e..0f3f7388a4b 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/platform/BackendCleanup.java +++ b/server/sonar-server/src/main/java/org/sonar/server/platform/BackendCleanup.java @@ -32,7 +32,7 @@ import org.sonar.api.server.ServerSide; import org.sonar.api.utils.log.Loggers; import org.sonar.db.DbSession; import org.sonar.db.MyBatis; -import org.sonar.db.version.DatabaseVersion; +import org.sonar.db.version.SqTables; import org.sonar.server.component.es.ProjectMeasuresIndexDefinition; import org.sonar.server.es.BulkIndexer; import org.sonar.server.es.EsClient; @@ -76,7 +76,7 @@ public class BackendCleanup { try (DbSession dbSession = myBatis.openSession(false); Connection connection = dbSession.getConnection(); Statement ddlStatement = connection.createStatement()) { - for (String tableName : DatabaseVersion.TABLES) { + for (String tableName : SqTables.TABLES) { Optional.ofNullable(TABLE_CLEANERS.get(tableName)) .orElse(BackendCleanup::truncateDefault) .clean(tableName, ddlStatement, connection); diff --git a/server/sonar-server/src/main/java/org/sonar/server/platform/DatabaseServerCompatibility.java b/server/sonar-server/src/main/java/org/sonar/server/platform/DatabaseServerCompatibility.java index db5548a95fe..ad44c4e2079 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/platform/DatabaseServerCompatibility.java +++ b/server/sonar-server/src/main/java/org/sonar/server/platform/DatabaseServerCompatibility.java @@ -22,7 +22,7 @@ package org.sonar.server.platform; import org.picocontainer.Startable; import org.sonar.api.utils.MessageException; import org.sonar.api.utils.log.Loggers; -import org.sonar.db.version.DatabaseVersion; +import org.sonar.server.platform.db.migration.version.DatabaseVersion; import static org.sonar.server.app.ServerProcessLogging.STARTUP_LOGGER_NAME; diff --git a/server/sonar-server/src/main/java/org/sonar/server/platform/DefaultServerUpgradeStatus.java b/server/sonar-server/src/main/java/org/sonar/server/platform/DefaultServerUpgradeStatus.java index cae8e5c0ea0..56b3df3f962 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/platform/DefaultServerUpgradeStatus.java +++ b/server/sonar-server/src/main/java/org/sonar/server/platform/DefaultServerUpgradeStatus.java @@ -23,7 +23,7 @@ import org.apache.commons.lang.builder.ReflectionToStringBuilder; import org.apache.commons.lang.builder.ToStringStyle; import org.picocontainer.Startable; import org.sonar.api.platform.ServerUpgradeStatus; -import org.sonar.db.version.DatabaseVersion; +import org.sonar.server.platform.db.migration.version.DatabaseVersion; /** * @since 2.5 diff --git a/server/sonar-server/src/main/java/org/sonar/server/platform/Platform.java b/server/sonar-server/src/main/java/org/sonar/server/platform/Platform.java index 44129da9357..95f86d74973 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/platform/Platform.java +++ b/server/sonar-server/src/main/java/org/sonar/server/platform/Platform.java @@ -30,7 +30,7 @@ import org.sonar.api.utils.log.Logger; import org.sonar.api.utils.log.Loggers; import org.sonar.api.utils.log.Profiler; import org.sonar.core.platform.ComponentContainer; -import org.sonar.db.version.DatabaseVersion; +import org.sonar.server.platform.db.migration.version.DatabaseVersion; import org.sonar.server.platform.platformlevel.PlatformLevel; import org.sonar.server.platform.platformlevel.PlatformLevel1; import org.sonar.server.platform.platformlevel.PlatformLevel2; diff --git a/server/sonar-server/src/main/java/org/sonar/server/platform/monitoring/DatabaseMonitor.java b/server/sonar-server/src/main/java/org/sonar/server/platform/monitoring/DatabaseMonitor.java index 4e957180552..3c56eefd5c4 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/platform/monitoring/DatabaseMonitor.java +++ b/server/sonar-server/src/main/java/org/sonar/server/platform/monitoring/DatabaseMonitor.java @@ -29,7 +29,7 @@ import org.apache.commons.dbutils.DbUtils; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.MyBatis; -import org.sonar.db.version.DatabaseVersion; +import org.sonar.server.platform.db.migration.version.DatabaseVersion; /** * Information about database and connection pool diff --git a/server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel2.java b/server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel2.java index a3bb6fc8fa7..bd1cd454b1b 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel2.java +++ b/server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel2.java @@ -24,7 +24,7 @@ import org.sonar.core.i18n.DefaultI18n; import org.sonar.core.i18n.RuleI18nManager; import org.sonar.core.platform.PluginClassloaderFactory; import org.sonar.core.platform.PluginLoader; -import org.sonar.db.version.DatabaseVersion; +import org.sonar.server.platform.db.migration.version.DatabaseVersion; import org.sonar.server.platform.DatabaseServerCompatibility; import org.sonar.server.platform.DefaultServerUpgradeStatus; import org.sonar.server.platform.StartupMetadataProvider; diff --git a/server/sonar-server/src/main/java/org/sonar/server/platform/ws/DbMigrationStatusAction.java b/server/sonar-server/src/main/java/org/sonar/server/platform/ws/DbMigrationStatusAction.java index d54ce3119f9..3e383c3ddc7 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/platform/ws/DbMigrationStatusAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/platform/ws/DbMigrationStatusAction.java @@ -25,7 +25,7 @@ import org.sonar.api.server.ws.Response; import org.sonar.api.server.ws.WebService; import org.sonar.api.utils.text.JsonWriter; import org.sonar.db.Database; -import org.sonar.db.version.DatabaseVersion; +import org.sonar.server.platform.db.migration.version.DatabaseVersion; import org.sonar.server.platform.db.migration.DatabaseMigrationState; import static com.google.common.base.Preconditions.checkState; diff --git a/server/sonar-server/src/main/java/org/sonar/server/platform/ws/MigrateDbAction.java b/server/sonar-server/src/main/java/org/sonar/server/platform/ws/MigrateDbAction.java index d8cccb93063..029dd1dfd4d 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/platform/ws/MigrateDbAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/platform/ws/MigrateDbAction.java @@ -25,7 +25,7 @@ import org.sonar.api.server.ws.Response; import org.sonar.api.server.ws.WebService; import org.sonar.api.utils.text.JsonWriter; import org.sonar.db.Database; -import org.sonar.db.version.DatabaseVersion; +import org.sonar.server.platform.db.migration.version.DatabaseVersion; import org.sonar.server.platform.db.migration.DatabaseMigration; import org.sonar.server.platform.db.migration.DatabaseMigrationState; diff --git a/server/sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java b/server/sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java index 9aa211f5fbc..de8a5bff789 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java +++ b/server/sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java @@ -49,7 +49,7 @@ import org.sonar.db.DbSession; import org.sonar.db.property.PropertiesDao; import org.sonar.db.property.PropertyDto; import org.sonar.db.rule.RuleRepositoryDto; -import org.sonar.db.version.DatabaseVersion; +import org.sonar.server.platform.db.migration.version.DatabaseVersion; import org.sonar.process.ProcessProperties; import org.sonar.server.authentication.IdentityProviderRepository; import org.sonar.server.component.ComponentCleanerService; diff --git a/server/sonar-server/src/test/java/org/sonar/server/platform/DatabaseServerCompatibilityTest.java b/server/sonar-server/src/test/java/org/sonar/server/platform/DatabaseServerCompatibilityTest.java index 2749a9b570a..687e25860a8 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/platform/DatabaseServerCompatibilityTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/platform/DatabaseServerCompatibilityTest.java @@ -25,7 +25,7 @@ import org.junit.rules.ExpectedException; import org.sonar.api.utils.MessageException; import org.sonar.api.utils.log.LogTester; import org.sonar.api.utils.log.LoggerLevel; -import org.sonar.db.version.DatabaseVersion; +import org.sonar.server.platform.db.migration.version.DatabaseVersion; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; diff --git a/server/sonar-server/src/test/java/org/sonar/server/platform/DefaultServerUpgradeStatusTest.java b/server/sonar-server/src/test/java/org/sonar/server/platform/DefaultServerUpgradeStatusTest.java index fdca3f984fc..4b7f2fca8d6 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/platform/DefaultServerUpgradeStatusTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/platform/DefaultServerUpgradeStatusTest.java @@ -20,7 +20,7 @@ package org.sonar.server.platform; import org.junit.Test; -import org.sonar.db.version.DatabaseVersion; +import org.sonar.server.platform.db.migration.version.DatabaseVersion; import static org.hamcrest.core.Is.is; import static org.junit.Assert.assertThat; diff --git a/server/sonar-server/src/test/java/org/sonar/server/platform/monitoring/DatabaseMonitorTest.java b/server/sonar-server/src/test/java/org/sonar/server/platform/monitoring/DatabaseMonitorTest.java index 9fcd6f1e6ff..228b19650e4 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/platform/monitoring/DatabaseMonitorTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/platform/monitoring/DatabaseMonitorTest.java @@ -24,7 +24,7 @@ import org.junit.Rule; import org.junit.Test; import org.sonar.api.utils.System2; import org.sonar.db.DbTester; -import org.sonar.db.version.DatabaseVersion; +import org.sonar.server.platform.db.migration.version.DatabaseVersion; import static org.assertj.core.api.Assertions.assertThat; diff --git a/server/sonar-server/src/test/java/org/sonar/server/platform/ws/DbMigrationStatusActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/platform/ws/DbMigrationStatusActionTest.java index c2741c62629..b5c833e7d1f 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/platform/ws/DbMigrationStatusActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/platform/ws/DbMigrationStatusActionTest.java @@ -32,7 +32,7 @@ import org.sonar.api.utils.DateUtils; import org.sonar.db.Database; import org.sonar.db.dialect.Dialect; import org.sonar.server.platform.db.migration.DatabaseMigrationState.Status; -import org.sonar.db.version.DatabaseVersion; +import org.sonar.server.platform.db.migration.version.DatabaseVersion; import org.sonar.server.platform.db.migration.DatabaseMigrationState; import org.sonar.server.ws.WsTester; diff --git a/server/sonar-server/src/test/java/org/sonar/server/platform/ws/MigrateDbActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/platform/ws/MigrateDbActionTest.java index 4fb43fb1584..64ef74ad62d 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/platform/ws/MigrateDbActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/platform/ws/MigrateDbActionTest.java @@ -33,7 +33,7 @@ import org.sonar.db.Database; import org.sonar.db.dialect.Dialect; import org.sonar.server.platform.db.migration.DatabaseMigration; import org.sonar.server.platform.db.migration.DatabaseMigrationState.Status; -import org.sonar.db.version.DatabaseVersion; +import org.sonar.server.platform.db.migration.version.DatabaseVersion; import org.sonar.server.platform.db.migration.DatabaseMigrationState; import org.sonar.server.ws.WsTester; diff --git a/sonar-db/src/main/java/org/sonar/db/version/DatabaseVersion.java b/sonar-db/src/main/java/org/sonar/db/version/SqTables.java index 6dcb89683e0..e08c27fdc89 100644 --- a/sonar-db/src/main/java/org/sonar/db/version/DatabaseVersion.java +++ b/sonar-db/src/main/java/org/sonar/db/version/SqTables.java @@ -19,33 +19,16 @@ */ package org.sonar.db.version; -import com.google.common.annotations.VisibleForTesting; import com.google.common.collect.ImmutableSet; -import java.util.Collections; -import java.util.List; import java.util.Set; -import javax.annotation.Nullable; -import org.sonar.db.DatabaseUtils; -import org.sonar.db.DbClient; -import org.sonar.db.DbSession; - -public class DatabaseVersion { - - public static final int LAST_VERSION = 1_502; - - /** - * The minimum supported version which can be upgraded. Lower - * versions must be previously upgraded to LTS version. - * Note that the value can't be less than current LTS version. - */ - public static final int MIN_UPGRADE_VERSION = 1_152; +public final class SqTables { /** * These tables are still involved in DB migrations, so potentially * incorrect collation must be fixed so that joins with other * tables are possible. * - * @see org.sonar.db.charset.ColumnDef#isInSonarQubeTable() + * @see org.sonar.db.charset.ColumnDef#isInSonarQubeTable() */ public static final Set<String> OLD_DROPPED_TABLES = ImmutableSet.of( "active_dashboards", @@ -109,47 +92,7 @@ public class DatabaseVersion { "user_tokens", "webhook_deliveries"); - private final DbClient dbClient; - - public DatabaseVersion(DbClient dbClient) { - this.dbClient = dbClient; - } - - @VisibleForTesting - static Status getStatus(@Nullable Integer currentVersion, int lastVersion) { - 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; - } - - public Status getStatus() { - return getStatus(getVersion(), LAST_VERSION); - } - - public Integer getVersion() { - try (DbSession dbSession = dbClient.openSession(false)) { - if (!DatabaseUtils.tableExists("SCHEMA_MIGRATIONS", dbSession.getConnection())) { - return null; - } - - List<Integer> versions = dbClient.schemaMigrationDao().selectVersions(dbSession); - if (!versions.isEmpty()) { - Collections.sort(versions); - return versions.get(versions.size() - 1); - } - return null; - } - } - - public enum Status { - UP_TO_DATE, REQUIRES_UPGRADE, REQUIRES_DOWNGRADE, FRESH_INSTALL + private SqTables() { + // prevents instantiation } } diff --git a/sonar-db/src/test/java/org/sonar/db/DatabaseCommands.java b/sonar-db/src/test/java/org/sonar/db/DatabaseCommands.java index 812ad84eb32..9ec7da2b031 100644 --- a/sonar-db/src/test/java/org/sonar/db/DatabaseCommands.java +++ b/sonar-db/src/test/java/org/sonar/db/DatabaseCommands.java @@ -43,7 +43,7 @@ import org.sonar.db.dialect.MsSql; import org.sonar.db.dialect.MySql; import org.sonar.db.dialect.Oracle; import org.sonar.db.dialect.PostgreSql; -import org.sonar.db.version.DatabaseVersion; +import org.sonar.db.version.SqTables; public abstract class DatabaseCommands { private final IDataTypeFactory dbUnitFactory; @@ -149,7 +149,7 @@ public abstract class DatabaseCommands { try { connection.setAutoCommit(false); statement = connection.createStatement(); - for (String table : DatabaseVersion.TABLES) { + for (String table : SqTables.TABLES) { try { if (shouldTruncate(connection, table)) { statement.executeUpdate(truncateSql(table)); @@ -193,7 +193,7 @@ public abstract class DatabaseCommands { connection.setAutoCommit(false); statement = connection.createStatement(); - for (String table : DatabaseVersion.TABLES) { + for (String table : SqTables.TABLES) { try { resultSet = statement.executeQuery("SELECT CASE WHEN MAX(ID) IS NULL THEN 1 ELSE MAX(ID)+1 END FROM " + table); resultSet.next(); |