From: Jacek Date: Mon, 18 Jan 2021 13:25:26 +0000 (+0100) Subject: SONAR-14335 Drop PK constraint by using select instead hardcoded name X-Git-Tag: 8.6.1.40680~3 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=0dbe912f80e67d86ec0a0c87427d6bfd9fb26ed7;p=sonarqube.git SONAR-14335 Drop PK constraint by using select instead hardcoded name - Move DropPrimaryKeySqlGenerator, AddPrimaryKeyBuilder and DbConstraintFinder to 'org.sonar.server.platform.db.migration.sql' package (cherry picked from commit fdfd28395271746cff870a45f8d2968709ed738a) --- diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/MigrationConfigurationModule.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/MigrationConfigurationModule.java index 373250ca965..4c0c32e8080 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/MigrationConfigurationModule.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/MigrationConfigurationModule.java @@ -22,6 +22,8 @@ package org.sonar.server.platform.db.migration; import org.sonar.core.platform.Module; import org.sonar.server.platform.db.migration.history.MigrationHistoryImpl; import org.sonar.server.platform.db.migration.history.MigrationHistoryMeddler; +import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder; +import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; import org.sonar.server.platform.db.migration.step.MigrationStepRegistryImpl; import org.sonar.server.platform.db.migration.step.MigrationStepsProvider; import org.sonar.server.platform.db.migration.version.v00.DbVersion00; @@ -30,8 +32,6 @@ import org.sonar.server.platform.db.migration.version.v81.DbVersion81; import org.sonar.server.platform.db.migration.version.v82.DbVersion82; import org.sonar.server.platform.db.migration.version.v83.DbVersion83; import org.sonar.server.platform.db.migration.version.v84.DbVersion84; -import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.version.v84.util.SqlHelper; import org.sonar.server.platform.db.migration.version.v85.DbVersion85; import org.sonar.server.platform.db.migration.version.v86.DbVersion86; @@ -57,8 +57,8 @@ public class MigrationConfigurationModule extends Module { MigrationHistoryImpl.class, MigrationHistoryMeddler.class, - // Only needed for 8.3 - SqlHelper.class, + // Utility classes + DbPrimaryKeyConstraintFinder.class, DropPrimaryKeySqlGenerator.class); } } diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/sql/AddPrimaryKeyBuilder.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/sql/AddPrimaryKeyBuilder.java new file mode 100644 index 00000000000..c80308081b6 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/sql/AddPrimaryKeyBuilder.java @@ -0,0 +1,48 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info 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.sql; + +import com.google.common.collect.Lists; +import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; + +import static com.google.common.base.Preconditions.checkState; +import static java.lang.String.format; +import static org.sonar.server.platform.db.migration.def.Validations.validateTableName; +import static org.sonar.server.platform.db.migration.sql.CreateTableBuilder.PRIMARY_KEY_PREFIX; + +public class AddPrimaryKeyBuilder { + + private final String tableName; + private final List primaryKey; + + public AddPrimaryKeyBuilder(String tableName, String column, String... moreColumns) { + this.tableName = validateTableName(tableName); + this.primaryKey = Lists.asList(column, moreColumns).stream().filter(Objects::nonNull).collect(Collectors.toList()); + } + + public String build() { + checkState(!primaryKey.isEmpty(), "Primary key is missing"); + return format("ALTER TABLE %s ADD CONSTRAINT %s%s PRIMARY KEY (%s)", tableName, PRIMARY_KEY_PREFIX, tableName, + String.join(",", this.primaryKey)); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/sql/DbPrimaryKeyConstraintFinder.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/sql/DbPrimaryKeyConstraintFinder.java new file mode 100644 index 00000000000..7736588483f --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/sql/DbPrimaryKeyConstraintFinder.java @@ -0,0 +1,130 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info 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.sql; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.Locale; +import java.util.Optional; +import org.sonar.db.Database; +import org.sonar.db.dialect.Dialect; +import org.sonar.db.dialect.H2; +import org.sonar.db.dialect.MsSql; +import org.sonar.db.dialect.Oracle; +import org.sonar.db.dialect.PostgreSql; + +import static java.lang.String.format; + +public class DbPrimaryKeyConstraintFinder { + + private final Database db; + + public DbPrimaryKeyConstraintFinder(Database db) { + this.db = db; + } + + public String findConstraintName(String tableName) throws SQLException { + String constraintQuery = getDbVendorSpecificQuery(tableName); + return executeQuery(constraintQuery) + .orElseThrow(() -> constraintNotFoundException(tableName)); + } + + String getDbVendorSpecificQuery(String tableName) { + Dialect dialect = db.getDialect(); + String constraintQuery; + switch (dialect.getId()) { + case PostgreSql.ID: + constraintQuery = getPostgresSqlConstraintQuery(tableName); + break; + case MsSql.ID: + constraintQuery = getMssqlConstraintQuery(tableName); + break; + case Oracle.ID: + constraintQuery = getOracleConstraintQuery(tableName); + break; + case H2.ID: + constraintQuery = getH2ConstraintQuery(tableName); + break; + default: + throw new IllegalStateException(format("Unsupported database '%s'", dialect.getId())); + } + return constraintQuery; + } + + private Optional executeQuery(String query) throws SQLException { + try (Connection connection = db.getDataSource().getConnection(); + PreparedStatement pstmt = connection + .prepareStatement(query); + ResultSet rs = pstmt.executeQuery()) { + if (rs.next()) { + return Optional.ofNullable(rs.getString(1)); + } + return Optional.empty(); + } + } + + private static String getPostgresSqlConstraintQuery(String tableName) { + return format("SELECT conname " + + "FROM pg_constraint " + + "WHERE conrelid = " + + " (SELECT oid " + + " FROM pg_class " + + " WHERE relname LIKE '%s')", tableName); + } + + private static String getMssqlConstraintQuery(String tableName) { + return format("SELECT name " + + "FROM sys.key_constraints " + + "WHERE type = 'PK' " + + "AND OBJECT_NAME(parent_object_id) = '%s'", tableName); + } + + private static String getOracleConstraintQuery(String tableName) { + return format("SELECT constraint_name " + + "FROM user_constraints " + + "WHERE table_name = UPPER('%s') " + + "AND constraint_type='P'", tableName); + } + + private static String getH2ConstraintQuery(String tableName) { + return format("SELECT constraint_name " + + "FROM information_schema.constraints " + + "WHERE table_name = '%s' and constraint_type = 'PRIMARY KEY'", tableName.toUpperCase(Locale.ENGLISH)); + } + + static IllegalStateException constraintNotFoundException(String tableName) { + return new IllegalStateException(format("Cannot find constraint for table '%s'", tableName)); + } + + // FIXME:: this method should be moved somewhere else + String getPostgresSqlSequence(String tableName, String columnName) throws SQLException { + try (Connection connection = db.getDataSource().getConnection(); + PreparedStatement pstmt = connection.prepareStatement(format("SELECT pg_get_serial_sequence('%s', '%s')", tableName, columnName)); + ResultSet rs = pstmt.executeQuery()) { + if (rs.next()) { + return rs.getString(1); + } + throw new IllegalStateException(format("Cannot find sequence for table '%s' on column '%s'", tableName, columnName)); + } + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/sql/DropConstraintBuilder.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/sql/DropConstraintBuilder.java index f61fc97eb7d..c4dbd3dbac5 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/sql/DropConstraintBuilder.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/sql/DropConstraintBuilder.java @@ -30,6 +30,11 @@ import static java.util.Collections.singletonList; import static org.sonar.server.platform.db.migration.def.Validations.validateIndexName; import static org.sonar.server.platform.db.migration.def.Validations.validateTableName; +/** + * This builder have the main goal to drop constraint of a column. + *

+ * It shouldn't be used to drop primary keys constraint, use {@link DropPrimaryKeySqlGenerator} + */ public class DropConstraintBuilder { private final Dialect dialect; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/sql/DropPrimaryKeySqlGenerator.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/sql/DropPrimaryKeySqlGenerator.java new file mode 100644 index 00000000000..cd965df6555 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/sql/DropPrimaryKeySqlGenerator.java @@ -0,0 +1,97 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info 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.sql; + +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; +import org.sonar.db.Database; +import org.sonar.db.dialect.Dialect; +import org.sonar.db.dialect.H2; +import org.sonar.db.dialect.MsSql; +import org.sonar.db.dialect.Oracle; +import org.sonar.db.dialect.PostgreSql; + +import static java.lang.String.format; +import static java.util.Collections.singletonList; + +public class DropPrimaryKeySqlGenerator { + private static final String GENERIC_DROP_CONSTRAINT_STATEMENT = "ALTER TABLE %s DROP CONSTRAINT %s"; + + private final Database db; + private final DbPrimaryKeyConstraintFinder dbConstraintFinder; + + public DropPrimaryKeySqlGenerator(Database db, DbPrimaryKeyConstraintFinder dbConstraintFinder) { + this.db = db; + this.dbConstraintFinder = dbConstraintFinder; + } + + public List generate(String tableName, String columnName, boolean isAutoGenerated) throws SQLException { + Dialect dialect = db.getDialect(); + String constraintName = dbConstraintFinder.findConstraintName(tableName); + switch (dialect.getId()) { + case PostgreSql.ID: + return generateForPostgresSql(tableName, columnName, constraintName); + case MsSql.ID: + return generateForMsSql(tableName, constraintName); + case Oracle.ID: + return generateForOracle(tableName, constraintName, isAutoGenerated); + case H2.ID: + return generateForH2(tableName, constraintName); + default: + throw new IllegalStateException(format("Unsupported database '%s'", dialect.getId())); + } + } + + private List generateForPostgresSql(String tableName, String column, String constraintName) throws SQLException { + List statements = new ArrayList<>(); + statements.add(format("ALTER TABLE %s ALTER COLUMN %s DROP DEFAULT", tableName, column)); + + String sequence = dbConstraintFinder.getPostgresSqlSequence(tableName, column); + if (sequence != null) { + statements.add(format("DROP SEQUENCE %s", sequence)); + } + + statements.add(format(GENERIC_DROP_CONSTRAINT_STATEMENT, tableName, constraintName)); + + return statements; + } + + private static List generateForOracle(String tableName, String constraintName, boolean isAutoGenerated) { + List statements = new ArrayList<>(); + if (isAutoGenerated) { + statements.add(format("DROP TRIGGER %s_IDT", tableName)); + statements.add(format("DROP SEQUENCE %s_SEQ", tableName)); + } + + // 'drop index' at the end ensures that associated index with primary key will be deleted + statements.add(format(GENERIC_DROP_CONSTRAINT_STATEMENT + " DROP INDEX", tableName, constraintName)); + return statements; + } + + private static List generateForMsSql(String tableName, String constraintName) { + return singletonList(format(GENERIC_DROP_CONSTRAINT_STATEMENT, tableName, constraintName)); + } + + private static List generateForH2(String tableName, String constraintName) { + return singletonList(format(GENERIC_DROP_CONSTRAINT_STATEMENT, tableName, constraintName)); + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/DropIdFromComponentsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/DropIdFromComponentsTable.java index c38a8c66368..9b6b6845583 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/DropIdFromComponentsTable.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/DropIdFromComponentsTable.java @@ -22,8 +22,8 @@ package org.sonar.server.platform.db.migration.version.v83; import java.sql.SQLException; import org.sonar.db.Database; import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; +import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; public class DropIdFromComponentsTable extends DdlChange { diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/AddPrimaryKeyOnUuidColumnOfActiveRuleParametersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/AddPrimaryKeyOnUuidColumnOfActiveRuleParametersTable.java index eecba7ac96c..e17439e5332 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/AddPrimaryKeyOnUuidColumnOfActiveRuleParametersTable.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/AddPrimaryKeyOnUuidColumnOfActiveRuleParametersTable.java @@ -21,8 +21,8 @@ package org.sonar.server.platform.db.migration.version.v84.activeruleparameters; import java.sql.SQLException; import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.AddPrimaryKeyBuilder; import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v84.util.AddPrimaryKeyBuilder; public class AddPrimaryKeyOnUuidColumnOfActiveRuleParametersTable extends DdlChange { diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/DropPrimaryKeyOnIdColumnOfActiveRuleParametersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/DropPrimaryKeyOnIdColumnOfActiveRuleParametersTable.java index 8d03f0e69d9..46072388afe 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/DropPrimaryKeyOnIdColumnOfActiveRuleParametersTable.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/DropPrimaryKeyOnIdColumnOfActiveRuleParametersTable.java @@ -20,8 +20,8 @@ package org.sonar.server.platform.db.migration.version.v84.activeruleparameters; import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; import org.sonar.server.platform.db.migration.version.v84.common.DropPrimaryKeyOnIdColumn; -import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; public class DropPrimaryKeyOnIdColumnOfActiveRuleParametersTable extends DropPrimaryKeyOnIdColumn { private static final String TABLE_NAME = "active_rule_parameters"; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activerules/AddPrimaryKeyOnUuidColumnOfActiveRulesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activerules/AddPrimaryKeyOnUuidColumnOfActiveRulesTable.java index 533804ceca5..b8e4b80ec4f 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activerules/AddPrimaryKeyOnUuidColumnOfActiveRulesTable.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activerules/AddPrimaryKeyOnUuidColumnOfActiveRulesTable.java @@ -21,8 +21,8 @@ package org.sonar.server.platform.db.migration.version.v84.activerules; import java.sql.SQLException; import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.AddPrimaryKeyBuilder; import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v84.util.AddPrimaryKeyBuilder; public class AddPrimaryKeyOnUuidColumnOfActiveRulesTable extends DdlChange { diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activerules/DropPrimaryKeyOnIdColumnOfActiveRulesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activerules/DropPrimaryKeyOnIdColumnOfActiveRulesTable.java index 325a330cc97..b5b43d8d325 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activerules/DropPrimaryKeyOnIdColumnOfActiveRulesTable.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/activerules/DropPrimaryKeyOnIdColumnOfActiveRulesTable.java @@ -20,8 +20,8 @@ package org.sonar.server.platform.db.migration.version.v84.activerules; import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; import org.sonar.server.platform.db.migration.version.v84.common.DropPrimaryKeyOnIdColumn; -import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; public class DropPrimaryKeyOnIdColumnOfActiveRulesTable extends DropPrimaryKeyOnIdColumn { private static final String TABLE_NAME = "active_rules"; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/ceactivity/AddPrimaryKeyOnUuidColumnOfCeActivityTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/ceactivity/AddPrimaryKeyOnUuidColumnOfCeActivityTable.java index e76cd130ac8..45ee47c8675 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/ceactivity/AddPrimaryKeyOnUuidColumnOfCeActivityTable.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/ceactivity/AddPrimaryKeyOnUuidColumnOfCeActivityTable.java @@ -21,8 +21,8 @@ package org.sonar.server.platform.db.migration.version.v84.ceactivity; import java.sql.SQLException; import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.AddPrimaryKeyBuilder; import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v84.util.AddPrimaryKeyBuilder; public class AddPrimaryKeyOnUuidColumnOfCeActivityTable extends DdlChange { diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/ceactivity/DropPrimaryKeyOnIdColumnOfCeActivityTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/ceactivity/DropPrimaryKeyOnIdColumnOfCeActivityTable.java index 6e8050569db..73901ff43e6 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/ceactivity/DropPrimaryKeyOnIdColumnOfCeActivityTable.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/ceactivity/DropPrimaryKeyOnIdColumnOfCeActivityTable.java @@ -20,8 +20,8 @@ package org.sonar.server.platform.db.migration.version.v84.ceactivity; import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; import org.sonar.server.platform.db.migration.version.v84.common.DropPrimaryKeyOnIdColumn; -import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; public class DropPrimaryKeyOnIdColumnOfCeActivityTable extends DropPrimaryKeyOnIdColumn { private static final String TABLE_NAME = "ce_activity"; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/cequeue/AddPrimaryKeyOnUuidColumnOfCeQueueTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/cequeue/AddPrimaryKeyOnUuidColumnOfCeQueueTable.java index cee57f12796..5b76b820d2b 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/cequeue/AddPrimaryKeyOnUuidColumnOfCeQueueTable.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/cequeue/AddPrimaryKeyOnUuidColumnOfCeQueueTable.java @@ -21,8 +21,8 @@ package org.sonar.server.platform.db.migration.version.v84.cequeue; import java.sql.SQLException; import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.AddPrimaryKeyBuilder; import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v84.util.AddPrimaryKeyBuilder; public class AddPrimaryKeyOnUuidColumnOfCeQueueTable extends DdlChange { diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/cequeue/DropPrimaryKeyOnIdColumnOfCeQueueTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/cequeue/DropPrimaryKeyOnIdColumnOfCeQueueTable.java index d893f90acf4..2687e49174a 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/cequeue/DropPrimaryKeyOnIdColumnOfCeQueueTable.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/cequeue/DropPrimaryKeyOnIdColumnOfCeQueueTable.java @@ -20,8 +20,8 @@ package org.sonar.server.platform.db.migration.version.v84.cequeue; import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; import org.sonar.server.platform.db.migration.version.v84.common.DropPrimaryKeyOnIdColumn; -import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; public class DropPrimaryKeyOnIdColumnOfCeQueueTable extends DropPrimaryKeyOnIdColumn { private static final String TABLE_NAME = "ce_queue"; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/common/DropPrimaryKeyOnIdColumn.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/common/DropPrimaryKeyOnIdColumn.java index ccb17dba7dc..c9a67edb082 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/common/DropPrimaryKeyOnIdColumn.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/common/DropPrimaryKeyOnIdColumn.java @@ -21,12 +21,12 @@ package org.sonar.server.platform.db.migration.version.v84.common; import java.sql.SQLException; import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; public abstract class DropPrimaryKeyOnIdColumn extends DdlChange { private final DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator; - private String tableName; + private final String tableName; protected DropPrimaryKeyOnIdColumn(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator, String tableName) { super(db); diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/AddPrimaryKeyOnUuidColumnOfDuplicationsIndexTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/AddPrimaryKeyOnUuidColumnOfDuplicationsIndexTable.java index 8cc709820f9..cbf21d0b8c1 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/AddPrimaryKeyOnUuidColumnOfDuplicationsIndexTable.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/AddPrimaryKeyOnUuidColumnOfDuplicationsIndexTable.java @@ -21,8 +21,8 @@ package org.sonar.server.platform.db.migration.version.v84.duplicationsindex; import java.sql.SQLException; import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.AddPrimaryKeyBuilder; import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v84.util.AddPrimaryKeyBuilder; public class AddPrimaryKeyOnUuidColumnOfDuplicationsIndexTable extends DdlChange { diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/DropPrimaryKeyOnIdColumnOfDuplicationsIndexTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/DropPrimaryKeyOnIdColumnOfDuplicationsIndexTable.java index 18990608534..cce9473f582 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/DropPrimaryKeyOnIdColumnOfDuplicationsIndexTable.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/DropPrimaryKeyOnIdColumnOfDuplicationsIndexTable.java @@ -20,8 +20,8 @@ package org.sonar.server.platform.db.migration.version.v84.duplicationsindex; import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; import org.sonar.server.platform.db.migration.version.v84.common.DropPrimaryKeyOnIdColumn; -import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; public class DropPrimaryKeyOnIdColumnOfDuplicationsIndexTable extends DropPrimaryKeyOnIdColumn { private static final String TABLE_NAME = "duplications_index"; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/events/AddPrimaryKeyOnUuidColumnOfEventsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/events/AddPrimaryKeyOnUuidColumnOfEventsTable.java index be9c8545a3b..1c4360b7184 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/events/AddPrimaryKeyOnUuidColumnOfEventsTable.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/events/AddPrimaryKeyOnUuidColumnOfEventsTable.java @@ -21,8 +21,8 @@ package org.sonar.server.platform.db.migration.version.v84.events; import java.sql.SQLException; import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.AddPrimaryKeyBuilder; import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v84.util.AddPrimaryKeyBuilder; public class AddPrimaryKeyOnUuidColumnOfEventsTable extends DdlChange { diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/events/DropPrimaryKeyOnIdColumnOfEventsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/events/DropPrimaryKeyOnIdColumnOfEventsTable.java index f2dc33dd070..20ed85bafad 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/events/DropPrimaryKeyOnIdColumnOfEventsTable.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/events/DropPrimaryKeyOnIdColumnOfEventsTable.java @@ -20,8 +20,8 @@ package org.sonar.server.platform.db.migration.version.v84.events; import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; import org.sonar.server.platform.db.migration.version.v84.common.DropPrimaryKeyOnIdColumn; -import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; public class DropPrimaryKeyOnIdColumnOfEventsTable extends DropPrimaryKeyOnIdColumn { private static final String TABLE_NAME = "events"; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/filesources/AddPrimaryKeyOnUuidColumnOfFileSourcesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/filesources/AddPrimaryKeyOnUuidColumnOfFileSourcesTable.java index 0a0c67869fd..e7600955d1e 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/filesources/AddPrimaryKeyOnUuidColumnOfFileSourcesTable.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/filesources/AddPrimaryKeyOnUuidColumnOfFileSourcesTable.java @@ -21,8 +21,8 @@ package org.sonar.server.platform.db.migration.version.v84.filesources; import java.sql.SQLException; import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.AddPrimaryKeyBuilder; import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v84.util.AddPrimaryKeyBuilder; public class AddPrimaryKeyOnUuidColumnOfFileSourcesTable extends DdlChange { diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/filesources/DropPrimaryKeyOnIdColumnOfFileSourcesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/filesources/DropPrimaryKeyOnIdColumnOfFileSourcesTable.java index 954e562f1ac..a3b77edee5f 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/filesources/DropPrimaryKeyOnIdColumnOfFileSourcesTable.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/filesources/DropPrimaryKeyOnIdColumnOfFileSourcesTable.java @@ -20,8 +20,8 @@ package org.sonar.server.platform.db.migration.version.v84.filesources; import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; import org.sonar.server.platform.db.migration.version.v84.common.DropPrimaryKeyOnIdColumn; -import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; public class DropPrimaryKeyOnIdColumnOfFileSourcesTable extends DropPrimaryKeyOnIdColumn { private static final String TABLE_NAME = "file_sources"; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/grouproles/AddPrimaryKeyOnUuidColumnOfGroupRolesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/grouproles/AddPrimaryKeyOnUuidColumnOfGroupRolesTable.java index d7d62af77a7..6676218cd50 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/grouproles/AddPrimaryKeyOnUuidColumnOfGroupRolesTable.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/grouproles/AddPrimaryKeyOnUuidColumnOfGroupRolesTable.java @@ -21,8 +21,8 @@ package org.sonar.server.platform.db.migration.version.v84.grouproles; import java.sql.SQLException; import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.AddPrimaryKeyBuilder; import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v84.util.AddPrimaryKeyBuilder; public class AddPrimaryKeyOnUuidColumnOfGroupRolesTable extends DdlChange { diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/grouproles/DropPrimaryKeyOnIdColumnOfGroupRolesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/grouproles/DropPrimaryKeyOnIdColumnOfGroupRolesTable.java index af8fa265219..41a97a8d4ae 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/grouproles/DropPrimaryKeyOnIdColumnOfGroupRolesTable.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/grouproles/DropPrimaryKeyOnIdColumnOfGroupRolesTable.java @@ -20,8 +20,8 @@ package org.sonar.server.platform.db.migration.version.v84.grouproles; import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; import org.sonar.server.platform.db.migration.version.v84.common.DropPrimaryKeyOnIdColumn; -import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; public class DropPrimaryKeyOnIdColumnOfGroupRolesTable extends DropPrimaryKeyOnIdColumn { private static final String TABLE_NAME = "group_roles"; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/AddPrimaryKeyOnUuidColumnOfGroupsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/AddPrimaryKeyOnUuidColumnOfGroupsTable.java index c3bc655bc81..47318814bb4 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/AddPrimaryKeyOnUuidColumnOfGroupsTable.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/AddPrimaryKeyOnUuidColumnOfGroupsTable.java @@ -21,8 +21,8 @@ package org.sonar.server.platform.db.migration.version.v84.groups; import java.sql.SQLException; import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.AddPrimaryKeyBuilder; import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v84.util.AddPrimaryKeyBuilder; public class AddPrimaryKeyOnUuidColumnOfGroupsTable extends DdlChange { diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/DropPrimaryKeyOnIdColumnOfGroupsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/DropPrimaryKeyOnIdColumnOfGroupsTable.java index 6759868372b..cee530a8c77 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/DropPrimaryKeyOnIdColumnOfGroupsTable.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/groups/DropPrimaryKeyOnIdColumnOfGroupsTable.java @@ -20,8 +20,8 @@ package org.sonar.server.platform.db.migration.version.v84.groups; import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; import org.sonar.server.platform.db.migration.version.v84.common.DropPrimaryKeyOnIdColumn; -import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; public class DropPrimaryKeyOnIdColumnOfGroupsTable extends DropPrimaryKeyOnIdColumn { private static final String TABLE_NAME = "groups"; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/issuechanges/AddPrimaryKeyOnUuidColumnOfIssueChangesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/issuechanges/AddPrimaryKeyOnUuidColumnOfIssueChangesTable.java index d8515339139..42974da5ebc 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/issuechanges/AddPrimaryKeyOnUuidColumnOfIssueChangesTable.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/issuechanges/AddPrimaryKeyOnUuidColumnOfIssueChangesTable.java @@ -21,8 +21,8 @@ package org.sonar.server.platform.db.migration.version.v84.issuechanges; import java.sql.SQLException; import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.AddPrimaryKeyBuilder; import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v84.util.AddPrimaryKeyBuilder; public class AddPrimaryKeyOnUuidColumnOfIssueChangesTable extends DdlChange { diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/issues/AddPrimaryKeyOnKeeColumnOfIssuesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/issues/AddPrimaryKeyOnKeeColumnOfIssuesTable.java index 9210d878ee2..c44c514a497 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/issues/AddPrimaryKeyOnKeeColumnOfIssuesTable.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/issues/AddPrimaryKeyOnKeeColumnOfIssuesTable.java @@ -21,8 +21,8 @@ package org.sonar.server.platform.db.migration.version.v84.issues; import java.sql.SQLException; import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.AddPrimaryKeyBuilder; import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v84.util.AddPrimaryKeyBuilder; public class AddPrimaryKeyOnKeeColumnOfIssuesTable extends DdlChange { private static final String TABLE_NAME = "issues"; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/manualmeasures/AddPrimaryKeyOnUuidColumnOfManualMeasuresTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/manualmeasures/AddPrimaryKeyOnUuidColumnOfManualMeasuresTable.java index cbcc2fca86b..8727da65182 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/manualmeasures/AddPrimaryKeyOnUuidColumnOfManualMeasuresTable.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/manualmeasures/AddPrimaryKeyOnUuidColumnOfManualMeasuresTable.java @@ -21,8 +21,8 @@ package org.sonar.server.platform.db.migration.version.v84.manualmeasures; import java.sql.SQLException; import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.AddPrimaryKeyBuilder; import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v84.util.AddPrimaryKeyBuilder; public class AddPrimaryKeyOnUuidColumnOfManualMeasuresTable extends DdlChange { diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/manualmeasures/DropPrimaryKeyOnIdColumnOfManualMeasuresTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/manualmeasures/DropPrimaryKeyOnIdColumnOfManualMeasuresTable.java index 72c50f74b68..5b0028e8aed 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/manualmeasures/DropPrimaryKeyOnIdColumnOfManualMeasuresTable.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/manualmeasures/DropPrimaryKeyOnIdColumnOfManualMeasuresTable.java @@ -21,8 +21,8 @@ package org.sonar.server.platform.db.migration.version.v84.manualmeasures; import java.sql.SQLException; import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; public class DropPrimaryKeyOnIdColumnOfManualMeasuresTable extends DdlChange { diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/AddPrimaryKeyOnUuidColumnOfMetricsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/AddPrimaryKeyOnUuidColumnOfMetricsTable.java index 708d91ad4df..40185a52fd2 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/AddPrimaryKeyOnUuidColumnOfMetricsTable.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/AddPrimaryKeyOnUuidColumnOfMetricsTable.java @@ -21,8 +21,8 @@ package org.sonar.server.platform.db.migration.version.v84.metrics; import java.sql.SQLException; import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.AddPrimaryKeyBuilder; import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v84.util.AddPrimaryKeyBuilder; public class AddPrimaryKeyOnUuidColumnOfMetricsTable extends DdlChange { diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/DropPrimaryKeyOnIdColumnOfMetricsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/DropPrimaryKeyOnIdColumnOfMetricsTable.java index 7b648ae092e..148c416a050 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/DropPrimaryKeyOnIdColumnOfMetricsTable.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/DropPrimaryKeyOnIdColumnOfMetricsTable.java @@ -20,8 +20,8 @@ package org.sonar.server.platform.db.migration.version.v84.metrics; import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; import org.sonar.server.platform.db.migration.version.v84.common.DropPrimaryKeyOnIdColumn; -import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; public class DropPrimaryKeyOnIdColumnOfMetricsTable extends DropPrimaryKeyOnIdColumn { private static final String TABLE_NAME = "metrics"; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/AddPKeyOnUuidOfLiveMeasuresTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/AddPKeyOnUuidOfLiveMeasuresTable.java index b1fefefb145..b98d91123ab 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/AddPKeyOnUuidOfLiveMeasuresTable.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/metrics/livemeasures/AddPKeyOnUuidOfLiveMeasuresTable.java @@ -21,8 +21,8 @@ package org.sonar.server.platform.db.migration.version.v84.metrics.livemeasures; import java.sql.SQLException; import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.AddPrimaryKeyBuilder; import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v84.util.AddPrimaryKeyBuilder; public class AddPKeyOnUuidOfLiveMeasuresTable extends DdlChange { private static final String TABLE_NAME = "live_measures"; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/notifications/AddPrimaryKeyOnUuidColumnOfNotificationTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/notifications/AddPrimaryKeyOnUuidColumnOfNotificationTable.java index 3b543820aaf..ea2f30d87b1 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/notifications/AddPrimaryKeyOnUuidColumnOfNotificationTable.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/notifications/AddPrimaryKeyOnUuidColumnOfNotificationTable.java @@ -21,8 +21,8 @@ package org.sonar.server.platform.db.migration.version.v84.notifications; import java.sql.SQLException; import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.AddPrimaryKeyBuilder; import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v84.util.AddPrimaryKeyBuilder; public class AddPrimaryKeyOnUuidColumnOfNotificationTable extends DdlChange { diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/notifications/DropPrimaryKeyOnIdColumnOfNotificationTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/notifications/DropPrimaryKeyOnIdColumnOfNotificationTable.java index f103794e537..4cfc4b317b4 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/notifications/DropPrimaryKeyOnIdColumnOfNotificationTable.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/notifications/DropPrimaryKeyOnIdColumnOfNotificationTable.java @@ -20,8 +20,8 @@ package org.sonar.server.platform.db.migration.version.v84.notifications; import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; import org.sonar.server.platform.db.migration.version.v84.common.DropPrimaryKeyOnIdColumn; -import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; public class DropPrimaryKeyOnIdColumnOfNotificationTable extends DropPrimaryKeyOnIdColumn { private static final String TABLE_NAME = "notifications"; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/AddPrimaryKeyOnUuidColumnOfPermissionTemplatesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/AddPrimaryKeyOnUuidColumnOfPermissionTemplatesTable.java index 02546b6fa3b..967e410b245 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/AddPrimaryKeyOnUuidColumnOfPermissionTemplatesTable.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/AddPrimaryKeyOnUuidColumnOfPermissionTemplatesTable.java @@ -21,8 +21,8 @@ package org.sonar.server.platform.db.migration.version.v84.permissiontemplates; import java.sql.SQLException; import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.AddPrimaryKeyBuilder; import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v84.util.AddPrimaryKeyBuilder; public class AddPrimaryKeyOnUuidColumnOfPermissionTemplatesTable extends DdlChange { diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/DropPrimaryKeyOnIdColumnOfPermissionTemplatesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/DropPrimaryKeyOnIdColumnOfPermissionTemplatesTable.java index dd699378242..be675e16f84 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/DropPrimaryKeyOnIdColumnOfPermissionTemplatesTable.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/DropPrimaryKeyOnIdColumnOfPermissionTemplatesTable.java @@ -20,8 +20,8 @@ package org.sonar.server.platform.db.migration.version.v84.permissiontemplates; import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; import org.sonar.server.platform.db.migration.version.v84.common.DropPrimaryKeyOnIdColumn; -import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; public class DropPrimaryKeyOnIdColumnOfPermissionTemplatesTable extends DropPrimaryKeyOnIdColumn { private static final String TABLE_NAME = "permission_templates"; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/AddPrimaryKeyOnUuidColumnOfPermTemplatesGroupsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/AddPrimaryKeyOnUuidColumnOfPermTemplatesGroupsTable.java index 0aaf0b182ba..6e82399f888 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/AddPrimaryKeyOnUuidColumnOfPermTemplatesGroupsTable.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/AddPrimaryKeyOnUuidColumnOfPermTemplatesGroupsTable.java @@ -21,8 +21,8 @@ package org.sonar.server.platform.db.migration.version.v84.permtemplatesgroups; import java.sql.SQLException; import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.AddPrimaryKeyBuilder; import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v84.util.AddPrimaryKeyBuilder; public class AddPrimaryKeyOnUuidColumnOfPermTemplatesGroupsTable extends DdlChange { diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/DropPrimaryKeyOnIdColumnOfPermTemplatesGroupsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/DropPrimaryKeyOnIdColumnOfPermTemplatesGroupsTable.java index 0411a6c8ad0..3ecc3dd1442 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/DropPrimaryKeyOnIdColumnOfPermTemplatesGroupsTable.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/DropPrimaryKeyOnIdColumnOfPermTemplatesGroupsTable.java @@ -20,8 +20,8 @@ package org.sonar.server.platform.db.migration.version.v84.permtemplatesgroups; import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; import org.sonar.server.platform.db.migration.version.v84.common.DropPrimaryKeyOnIdColumn; -import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; public class DropPrimaryKeyOnIdColumnOfPermTemplatesGroupsTable extends DropPrimaryKeyOnIdColumn { private static final String TABLE_NAME = "perm_templates_groups"; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/AddPrimaryKeyOnUuidColumnOfPermTemplatesUsersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/AddPrimaryKeyOnUuidColumnOfPermTemplatesUsersTable.java index baf679d9b42..6afee11dbea 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/AddPrimaryKeyOnUuidColumnOfPermTemplatesUsersTable.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/AddPrimaryKeyOnUuidColumnOfPermTemplatesUsersTable.java @@ -21,8 +21,8 @@ package org.sonar.server.platform.db.migration.version.v84.permtemplatesusers; import java.sql.SQLException; import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.AddPrimaryKeyBuilder; import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v84.util.AddPrimaryKeyBuilder; public class AddPrimaryKeyOnUuidColumnOfPermTemplatesUsersTable extends DdlChange { diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/DropPrimaryKeyOnIdColumnOfPermTemplatesUsersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/DropPrimaryKeyOnIdColumnOfPermTemplatesUsersTable.java index 209d31fe87c..44d526d4c2b 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/DropPrimaryKeyOnIdColumnOfPermTemplatesUsersTable.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/DropPrimaryKeyOnIdColumnOfPermTemplatesUsersTable.java @@ -20,8 +20,8 @@ package org.sonar.server.platform.db.migration.version.v84.permtemplatesusers; import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; import org.sonar.server.platform.db.migration.version.v84.common.DropPrimaryKeyOnIdColumn; -import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; public class DropPrimaryKeyOnIdColumnOfPermTemplatesUsersTable extends DropPrimaryKeyOnIdColumn { private static final String TABLE_NAME = "perm_templates_users"; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/AddPrimaryKeyOnUuidColumnOfPermTplCharacteristicsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/AddPrimaryKeyOnUuidColumnOfPermTplCharacteristicsTable.java index 348635f10b3..91d083efd56 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/AddPrimaryKeyOnUuidColumnOfPermTplCharacteristicsTable.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/AddPrimaryKeyOnUuidColumnOfPermTplCharacteristicsTable.java @@ -21,8 +21,8 @@ package org.sonar.server.platform.db.migration.version.v84.permtplcharacteristic import java.sql.SQLException; import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.AddPrimaryKeyBuilder; import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v84.util.AddPrimaryKeyBuilder; public class AddPrimaryKeyOnUuidColumnOfPermTplCharacteristicsTable extends DdlChange { diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/DropPrimaryKeyOnIdColumnOfPermTplCharacteristicsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/DropPrimaryKeyOnIdColumnOfPermTplCharacteristicsTable.java index 96375daccbe..c693aaeddf7 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/DropPrimaryKeyOnIdColumnOfPermTplCharacteristicsTable.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/DropPrimaryKeyOnIdColumnOfPermTplCharacteristicsTable.java @@ -20,8 +20,8 @@ package org.sonar.server.platform.db.migration.version.v84.permtplcharacteristics; import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; import org.sonar.server.platform.db.migration.version.v84.common.DropPrimaryKeyOnIdColumn; -import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; public class DropPrimaryKeyOnIdColumnOfPermTplCharacteristicsTable extends DropPrimaryKeyOnIdColumn { private static final String TABLE_NAME = "perm_tpl_characteristics"; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/AddPrimaryKeyOnUuidColumnOfProjectMeasuresTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/AddPrimaryKeyOnUuidColumnOfProjectMeasuresTable.java index 312c9bd86ed..a72fb11c2b2 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/AddPrimaryKeyOnUuidColumnOfProjectMeasuresTable.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/AddPrimaryKeyOnUuidColumnOfProjectMeasuresTable.java @@ -21,8 +21,8 @@ package org.sonar.server.platform.db.migration.version.v84.projectmeasures; import java.sql.SQLException; import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.AddPrimaryKeyBuilder; import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v84.util.AddPrimaryKeyBuilder; public class AddPrimaryKeyOnUuidColumnOfProjectMeasuresTable extends DdlChange { diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/DropPrimaryKeyOnIdColumnOfProjectMeasuresTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/DropPrimaryKeyOnIdColumnOfProjectMeasuresTable.java index f37523647bc..09aeee4b2cb 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/DropPrimaryKeyOnIdColumnOfProjectMeasuresTable.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/DropPrimaryKeyOnIdColumnOfProjectMeasuresTable.java @@ -20,8 +20,8 @@ package org.sonar.server.platform.db.migration.version.v84.projectmeasures; import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; import org.sonar.server.platform.db.migration.version.v84.common.DropPrimaryKeyOnIdColumn; -import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; public class DropPrimaryKeyOnIdColumnOfProjectMeasuresTable extends DropPrimaryKeyOnIdColumn { private static final String TABLE_NAME = "project_measures"; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/AddPrimaryKeyOnUuidColumnOfProjectQProfilesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/AddPrimaryKeyOnUuidColumnOfProjectQProfilesTable.java index c47e26cb3d0..f3403e23053 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/AddPrimaryKeyOnUuidColumnOfProjectQProfilesTable.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/AddPrimaryKeyOnUuidColumnOfProjectQProfilesTable.java @@ -21,8 +21,8 @@ package org.sonar.server.platform.db.migration.version.v84.projectqprofiles; import java.sql.SQLException; import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.AddPrimaryKeyBuilder; import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v84.util.AddPrimaryKeyBuilder; public class AddPrimaryKeyOnUuidColumnOfProjectQProfilesTable extends DdlChange { diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/DropPrimaryKeyOnIdColumnOfProjectQProfilesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/DropPrimaryKeyOnIdColumnOfProjectQProfilesTable.java index fb86b8b1df8..361339b7aad 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/DropPrimaryKeyOnIdColumnOfProjectQProfilesTable.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/DropPrimaryKeyOnIdColumnOfProjectQProfilesTable.java @@ -21,8 +21,8 @@ package org.sonar.server.platform.db.migration.version.v84.projectqprofiles; import java.sql.SQLException; import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; public class DropPrimaryKeyOnIdColumnOfProjectQProfilesTable extends DdlChange { diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/properties/AddPrimaryKeyOnUuidColumnOfPropertiesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/properties/AddPrimaryKeyOnUuidColumnOfPropertiesTable.java index d86eb0578e9..3bc5072abca 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/properties/AddPrimaryKeyOnUuidColumnOfPropertiesTable.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/properties/AddPrimaryKeyOnUuidColumnOfPropertiesTable.java @@ -21,8 +21,8 @@ package org.sonar.server.platform.db.migration.version.v84.properties; import java.sql.SQLException; import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.AddPrimaryKeyBuilder; import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v84.util.AddPrimaryKeyBuilder; public class AddPrimaryKeyOnUuidColumnOfPropertiesTable extends DdlChange { diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/properties/DropPrimaryKeyOnIdColumnOfPropertiesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/properties/DropPrimaryKeyOnIdColumnOfPropertiesTable.java index 53d1f0fa259..b6b6ac90007 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/properties/DropPrimaryKeyOnIdColumnOfPropertiesTable.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/properties/DropPrimaryKeyOnIdColumnOfPropertiesTable.java @@ -20,8 +20,8 @@ package org.sonar.server.platform.db.migration.version.v84.properties; import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; import org.sonar.server.platform.db.migration.version.v84.common.DropPrimaryKeyOnIdColumn; -import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; public class DropPrimaryKeyOnIdColumnOfPropertiesTable extends DropPrimaryKeyOnIdColumn { diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/AddPrimaryKeyOnUuidColumnOfQualityGateConditionsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/AddPrimaryKeyOnUuidColumnOfQualityGateConditionsTable.java index 7cb786d5d53..25128093914 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/AddPrimaryKeyOnUuidColumnOfQualityGateConditionsTable.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/AddPrimaryKeyOnUuidColumnOfQualityGateConditionsTable.java @@ -21,8 +21,8 @@ package org.sonar.server.platform.db.migration.version.v84.qualitygateconditions import java.sql.SQLException; import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.AddPrimaryKeyBuilder; import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v84.util.AddPrimaryKeyBuilder; public class AddPrimaryKeyOnUuidColumnOfQualityGateConditionsTable extends DdlChange { diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/DropPrimaryKeyOnIdColumnOfQualityGateConditionsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/DropPrimaryKeyOnIdColumnOfQualityGateConditionsTable.java index 5008c4068a8..3a6f5d2f6e3 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/DropPrimaryKeyOnIdColumnOfQualityGateConditionsTable.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/DropPrimaryKeyOnIdColumnOfQualityGateConditionsTable.java @@ -20,8 +20,8 @@ package org.sonar.server.platform.db.migration.version.v84.qualitygateconditions; import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; import org.sonar.server.platform.db.migration.version.v84.common.DropPrimaryKeyOnIdColumn; -import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; public class DropPrimaryKeyOnIdColumnOfQualityGateConditionsTable extends DropPrimaryKeyOnIdColumn { private static final String TABLE_NAME = "quality_gate_conditions"; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/AddPrimaryKeyOnUuidColumnOfQGatesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/AddPrimaryKeyOnUuidColumnOfQGatesTable.java index 13881446536..c0b5fce718f 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/AddPrimaryKeyOnUuidColumnOfQGatesTable.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/AddPrimaryKeyOnUuidColumnOfQGatesTable.java @@ -21,8 +21,8 @@ package org.sonar.server.platform.db.migration.version.v84.qualitygates; import java.sql.SQLException; import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.AddPrimaryKeyBuilder; import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v84.util.AddPrimaryKeyBuilder; public class AddPrimaryKeyOnUuidColumnOfQGatesTable extends DdlChange { diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropPrimaryKeyOnIdColumnOfQGatesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropPrimaryKeyOnIdColumnOfQGatesTable.java index d163d436f74..2681535bd5d 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropPrimaryKeyOnIdColumnOfQGatesTable.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropPrimaryKeyOnIdColumnOfQGatesTable.java @@ -20,8 +20,8 @@ package org.sonar.server.platform.db.migration.version.v84.qualitygates; import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; import org.sonar.server.platform.db.migration.version.v84.common.DropPrimaryKeyOnIdColumn; -import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; public class DropPrimaryKeyOnIdColumnOfQGatesTable extends DropPrimaryKeyOnIdColumn { diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/AddPrimaryKeyOnUuidColumnOfRulesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/AddPrimaryKeyOnUuidColumnOfRulesTable.java index 2b4c6b6aefc..ff621df1d0c 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/AddPrimaryKeyOnUuidColumnOfRulesTable.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/AddPrimaryKeyOnUuidColumnOfRulesTable.java @@ -21,8 +21,8 @@ package org.sonar.server.platform.db.migration.version.v84.rules; import java.sql.SQLException; import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.AddPrimaryKeyBuilder; import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v84.util.AddPrimaryKeyBuilder; public class AddPrimaryKeyOnUuidColumnOfRulesTable extends DdlChange { diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/DropPrimaryKeyOnIdColumnOfRulesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/DropPrimaryKeyOnIdColumnOfRulesTable.java index 362aa8873ed..7a31d61f957 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/DropPrimaryKeyOnIdColumnOfRulesTable.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/DropPrimaryKeyOnIdColumnOfRulesTable.java @@ -21,8 +21,8 @@ package org.sonar.server.platform.db.migration.version.v84.rules; import java.sql.SQLException; import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; public class DropPrimaryKeyOnIdColumnOfRulesTable extends DdlChange { diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/AddPrimaryKeyOnUuidAndOrganizationUuidColumnOfRulesMetadataTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/AddPrimaryKeyOnUuidAndOrganizationUuidColumnOfRulesMetadataTable.java index fad1c61489f..9e21632f3b3 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/AddPrimaryKeyOnUuidAndOrganizationUuidColumnOfRulesMetadataTable.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/AddPrimaryKeyOnUuidAndOrganizationUuidColumnOfRulesMetadataTable.java @@ -21,8 +21,8 @@ package org.sonar.server.platform.db.migration.version.v84.rules.rulesmetadata; import java.sql.SQLException; import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.AddPrimaryKeyBuilder; import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v84.util.AddPrimaryKeyBuilder; public class AddPrimaryKeyOnUuidAndOrganizationUuidColumnOfRulesMetadataTable extends DdlChange { diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/DropPrimaryKeyOnIdColumnOfRulesMetadataTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/DropPrimaryKeyOnIdColumnOfRulesMetadataTable.java index 62ff3000211..71ce8f41b3f 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/DropPrimaryKeyOnIdColumnOfRulesMetadataTable.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/DropPrimaryKeyOnIdColumnOfRulesMetadataTable.java @@ -21,8 +21,8 @@ package org.sonar.server.platform.db.migration.version.v84.rules.rulesmetadata; import java.sql.SQLException; import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; public class DropPrimaryKeyOnIdColumnOfRulesMetadataTable extends DdlChange { diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/AddPrimaryKeyOnUuidColumnOfRulesParametersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/AddPrimaryKeyOnUuidColumnOfRulesParametersTable.java index d2fd3271aeb..139caacf744 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/AddPrimaryKeyOnUuidColumnOfRulesParametersTable.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/AddPrimaryKeyOnUuidColumnOfRulesParametersTable.java @@ -21,8 +21,8 @@ package org.sonar.server.platform.db.migration.version.v84.rulesparameters; import java.sql.SQLException; import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.AddPrimaryKeyBuilder; import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v84.util.AddPrimaryKeyBuilder; public class AddPrimaryKeyOnUuidColumnOfRulesParametersTable extends DdlChange { diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/DropPrimaryKeyOnIdColumnOfRulesParametersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/DropPrimaryKeyOnIdColumnOfRulesParametersTable.java index f2b4984d361..c9e4462b1bb 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/DropPrimaryKeyOnIdColumnOfRulesParametersTable.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/DropPrimaryKeyOnIdColumnOfRulesParametersTable.java @@ -20,8 +20,8 @@ package org.sonar.server.platform.db.migration.version.v84.rulesparameters; import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; import org.sonar.server.platform.db.migration.version.v84.common.DropPrimaryKeyOnIdColumn; -import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; public class DropPrimaryKeyOnIdColumnOfRulesParametersTable extends DropPrimaryKeyOnIdColumn { private static final String TABLE_NAME = "rules_parameters"; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/AddPrimaryKeyOnUuidColumnOfRulesProfilesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/AddPrimaryKeyOnUuidColumnOfRulesProfilesTable.java index e0be6487c77..42b57d69e58 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/AddPrimaryKeyOnUuidColumnOfRulesProfilesTable.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/AddPrimaryKeyOnUuidColumnOfRulesProfilesTable.java @@ -21,8 +21,8 @@ package org.sonar.server.platform.db.migration.version.v84.rulesprofiles; import java.sql.SQLException; import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.AddPrimaryKeyBuilder; import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v84.util.AddPrimaryKeyBuilder; public class AddPrimaryKeyOnUuidColumnOfRulesProfilesTable extends DdlChange { diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/DropPrimaryKeyOnIdColumnOfRulesProfilesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/DropPrimaryKeyOnIdColumnOfRulesProfilesTable.java index ecbece18360..86ad970794f 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/DropPrimaryKeyOnIdColumnOfRulesProfilesTable.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/DropPrimaryKeyOnIdColumnOfRulesProfilesTable.java @@ -20,8 +20,8 @@ package org.sonar.server.platform.db.migration.version.v84.rulesprofiles; import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; import org.sonar.server.platform.db.migration.version.v84.common.DropPrimaryKeyOnIdColumn; -import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; public class DropPrimaryKeyOnIdColumnOfRulesProfilesTable extends DropPrimaryKeyOnIdColumn { private static final String TABLE_NAME = "rules_profiles"; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/snapshots/issues/AddPrimaryKeyOnUuidColumnOfSnapshotsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/snapshots/issues/AddPrimaryKeyOnUuidColumnOfSnapshotsTable.java index f6654ab66ee..f063c3822f6 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/snapshots/issues/AddPrimaryKeyOnUuidColumnOfSnapshotsTable.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/snapshots/issues/AddPrimaryKeyOnUuidColumnOfSnapshotsTable.java @@ -21,8 +21,8 @@ package org.sonar.server.platform.db.migration.version.v84.snapshots.issues; import java.sql.SQLException; import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.AddPrimaryKeyBuilder; import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v84.util.AddPrimaryKeyBuilder; public class AddPrimaryKeyOnUuidColumnOfSnapshotsTable extends DdlChange { diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/snapshots/issues/DropPrimaryKeyOnIdColumnOfSnapshotsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/snapshots/issues/DropPrimaryKeyOnIdColumnOfSnapshotsTable.java index c79ad62a279..a9f0ff948a6 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/snapshots/issues/DropPrimaryKeyOnIdColumnOfSnapshotsTable.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/snapshots/issues/DropPrimaryKeyOnIdColumnOfSnapshotsTable.java @@ -21,8 +21,8 @@ package org.sonar.server.platform.db.migration.version.v84.snapshots.issues; import java.sql.SQLException; import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; public class DropPrimaryKeyOnIdColumnOfSnapshotsTable extends DdlChange { diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/userroles/AddPrimaryKeyOnUuidColumnOfUserRolesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/userroles/AddPrimaryKeyOnUuidColumnOfUserRolesTable.java index 098d8282453..7204570bbb5 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/userroles/AddPrimaryKeyOnUuidColumnOfUserRolesTable.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/userroles/AddPrimaryKeyOnUuidColumnOfUserRolesTable.java @@ -21,8 +21,8 @@ package org.sonar.server.platform.db.migration.version.v84.userroles; import java.sql.SQLException; import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.AddPrimaryKeyBuilder; import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v84.util.AddPrimaryKeyBuilder; public class AddPrimaryKeyOnUuidColumnOfUserRolesTable extends DdlChange { diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/userroles/DropPrimaryKeyOnIdColumnOfUserRolesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/userroles/DropPrimaryKeyOnIdColumnOfUserRolesTable.java index 3bf847a3070..5ebcfd2b32a 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/userroles/DropPrimaryKeyOnIdColumnOfUserRolesTable.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/userroles/DropPrimaryKeyOnIdColumnOfUserRolesTable.java @@ -20,8 +20,8 @@ package org.sonar.server.platform.db.migration.version.v84.userroles; import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; import org.sonar.server.platform.db.migration.version.v84.common.DropPrimaryKeyOnIdColumn; -import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; public class DropPrimaryKeyOnIdColumnOfUserRolesTable extends DropPrimaryKeyOnIdColumn { private static final String TABLE_NAME = "user_roles"; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/AddPrimaryKeyOnUuidColumnOfUsersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/AddPrimaryKeyOnUuidColumnOfUsersTable.java index 94dd321dae9..5a9439c31c9 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/AddPrimaryKeyOnUuidColumnOfUsersTable.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/AddPrimaryKeyOnUuidColumnOfUsersTable.java @@ -21,8 +21,8 @@ package org.sonar.server.platform.db.migration.version.v84.users; import java.sql.SQLException; import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.AddPrimaryKeyBuilder; import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v84.util.AddPrimaryKeyBuilder; public class AddPrimaryKeyOnUuidColumnOfUsersTable extends DdlChange { diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/DropPrimaryKeyOnIdColumnOfUsersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/DropPrimaryKeyOnIdColumnOfUsersTable.java index 923745c3c95..daa454ca559 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/DropPrimaryKeyOnIdColumnOfUsersTable.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/DropPrimaryKeyOnIdColumnOfUsersTable.java @@ -20,8 +20,8 @@ package org.sonar.server.platform.db.migration.version.v84.users; import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; import org.sonar.server.platform.db.migration.version.v84.common.DropPrimaryKeyOnIdColumn; -import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; public class DropPrimaryKeyOnIdColumnOfUsersTable extends DropPrimaryKeyOnIdColumn { diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/AddPrimaryKeyOnUserUuidAndOrganizationUuidColumnsOfUserRolesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/AddPrimaryKeyOnUserUuidAndOrganizationUuidColumnsOfUserRolesTable.java index 20bc5d8f6c6..5fe52e6dc8f 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/AddPrimaryKeyOnUserUuidAndOrganizationUuidColumnsOfUserRolesTable.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/AddPrimaryKeyOnUserUuidAndOrganizationUuidColumnsOfUserRolesTable.java @@ -21,8 +21,8 @@ package org.sonar.server.platform.db.migration.version.v84.users.fk.organization import java.sql.SQLException; import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.AddPrimaryKeyBuilder; import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v84.util.AddPrimaryKeyBuilder; public class AddPrimaryKeyOnUserUuidAndOrganizationUuidColumnsOfUserRolesTable extends DdlChange { diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/DropPrimaryKeyOnUserIdAndOrganizationUuidOfOrganizationMembersTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/DropPrimaryKeyOnUserIdAndOrganizationUuidOfOrganizationMembersTable.java index 0a8f74b2548..ca9e233325a 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/DropPrimaryKeyOnUserIdAndOrganizationUuidOfOrganizationMembersTable.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/DropPrimaryKeyOnUserIdAndOrganizationUuidOfOrganizationMembersTable.java @@ -21,8 +21,8 @@ package org.sonar.server.platform.db.migration.version.v84.users.fk.organization import java.sql.SQLException; import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; public class DropPrimaryKeyOnUserIdAndOrganizationUuidOfOrganizationMembersTable extends DdlChange { private static final String TABLE_NAME = "organization_members"; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/usertokens/AddPrimaryKeyOnUuidColumnOfUserTokensTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/usertokens/AddPrimaryKeyOnUuidColumnOfUserTokensTable.java index 114aaaef179..4c591ec5a20 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/usertokens/AddPrimaryKeyOnUuidColumnOfUserTokensTable.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/usertokens/AddPrimaryKeyOnUuidColumnOfUserTokensTable.java @@ -21,8 +21,8 @@ package org.sonar.server.platform.db.migration.version.v84.usertokens; import java.sql.SQLException; import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.AddPrimaryKeyBuilder; import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v84.util.AddPrimaryKeyBuilder; public class AddPrimaryKeyOnUuidColumnOfUserTokensTable extends DdlChange { diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/usertokens/DropPrimaryKeyOnIdColumnOfUserTokensTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/usertokens/DropPrimaryKeyOnIdColumnOfUserTokensTable.java index ef09bb82587..1ea943ef4bc 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/usertokens/DropPrimaryKeyOnIdColumnOfUserTokensTable.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/usertokens/DropPrimaryKeyOnIdColumnOfUserTokensTable.java @@ -20,8 +20,8 @@ package org.sonar.server.platform.db.migration.version.v84.usertokens; import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; import org.sonar.server.platform.db.migration.version.v84.common.DropPrimaryKeyOnIdColumn; -import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; public class DropPrimaryKeyOnIdColumnOfUserTokensTable extends DropPrimaryKeyOnIdColumn { private static final String TABLE_NAME = "user_tokens"; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/util/AddPrimaryKeyBuilder.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/util/AddPrimaryKeyBuilder.java deleted file mode 100644 index 8772a2a1ec3..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/util/AddPrimaryKeyBuilder.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info 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.v84.util; - -import com.google.common.collect.Lists; -import java.util.List; - -import static com.google.common.base.Preconditions.checkState; -import static java.lang.String.format; -import static org.sonar.server.platform.db.migration.def.Validations.validateTableName; -import static org.sonar.server.platform.db.migration.sql.CreateTableBuilder.PRIMARY_KEY_PREFIX; - -public class AddPrimaryKeyBuilder { - - private final String tableName; - private final List primaryKey; - - public AddPrimaryKeyBuilder(String tableName, String column, String... moreColumns) { - this.tableName = validateTableName(tableName); - this.primaryKey = Lists.asList(column, moreColumns); - } - - public String build() { - checkState(primaryKey != null, "Primary key is missing"); - return format("ALTER TABLE %s ADD CONSTRAINT %s%s PRIMARY KEY (%s)", tableName, PRIMARY_KEY_PREFIX, tableName, - String.join(",", this.primaryKey)); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/util/DropPrimaryKeySqlGenerator.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/util/DropPrimaryKeySqlGenerator.java deleted file mode 100644 index 81a317fa09a..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/util/DropPrimaryKeySqlGenerator.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info 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.v84.util; - -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.List; -import org.sonar.db.Database; -import org.sonar.db.dialect.Dialect; -import org.sonar.db.dialect.H2; -import org.sonar.db.dialect.MsSql; -import org.sonar.db.dialect.Oracle; -import org.sonar.db.dialect.PostgreSql; - -import static java.lang.String.format; -import static java.util.Arrays.asList; -import static java.util.Collections.singletonList; - -public class DropPrimaryKeySqlGenerator { - private static final String GENERIC_DROP_CONSTRAINT_STATEMENT = "ALTER TABLE %s DROP CONSTRAINT %s"; - - private final Database db; - private SqlHelper sqlHelper; - - public DropPrimaryKeySqlGenerator(Database db, SqlHelper sqlHelper) { - this.db = db; - this.sqlHelper = sqlHelper; - } - - public List generate(String tableName, String columnName, boolean isAutoGenerated) throws SQLException { - Dialect dialect = db.getDialect(); - switch (dialect.getId()) { - case PostgreSql.ID: - return generateForPostgresSql(tableName, columnName, sqlHelper.getPostgresSqlConstraint(tableName)); - case MsSql.ID: - return generateForMsSql(tableName, sqlHelper.getMssqlConstraint(tableName)); - case Oracle.ID: - return generateForOracle(tableName, sqlHelper.getOracleConstraint(tableName), isAutoGenerated); - case H2.ID: - return generateForH2(tableName, columnName, sqlHelper.getH2Constraint(tableName)); - default: - throw new IllegalStateException(format("Unsupported database '%s'", dialect.getId())); - } - } - - private List generateForPostgresSql(String tableName, String column, String constraintName) throws SQLException { - List statements = new ArrayList<>(); - statements.add(format("ALTER TABLE %s ALTER COLUMN %s DROP DEFAULT", tableName, column)); - - String sequence = sqlHelper.getPostgresSqlSequence(tableName, column); - if (sequence != null) { - statements.add(format("DROP SEQUENCE %s", sequence)); - } - - statements.add(format(GENERIC_DROP_CONSTRAINT_STATEMENT, tableName, constraintName)); - - return statements; - } - - private static List generateForOracle(String tableName, String constraintName, boolean isAutoGenerated) { - List statements = new ArrayList<>(); - if (isAutoGenerated) { - statements.add(format("DROP TRIGGER %s_IDT", tableName)); - statements.add(format("DROP SEQUENCE %s_SEQ", tableName)); - } - - // 'drop index' at the end ensures that associated index with primary key will be deleted - statements.add(format(GENERIC_DROP_CONSTRAINT_STATEMENT + " DROP INDEX", tableName, constraintName)); - return statements; - } - - private static List generateForMsSql(String tableName, String constraintName) { - return singletonList(format(GENERIC_DROP_CONSTRAINT_STATEMENT, tableName, constraintName)); - } - - private static List generateForH2(String tableName, String column, String constraintName) { - return asList( - format(GENERIC_DROP_CONSTRAINT_STATEMENT, tableName, constraintName), - format("ALTER TABLE %s ALTER COLUMN %s INTEGER NOT NULL", tableName, column)); - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/AddPrimaryKeyOnUuidForIssueChangesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/AddPrimaryKeyOnUuidForIssueChangesTable.java index 2ba54f4a737..6e6b8018237 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/AddPrimaryKeyOnUuidForIssueChangesTable.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v85/AddPrimaryKeyOnUuidForIssueChangesTable.java @@ -21,8 +21,8 @@ package org.sonar.server.platform.db.migration.version.v85; import java.sql.SQLException; import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.AddPrimaryKeyBuilder; import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v84.util.AddPrimaryKeyBuilder; public class AddPrimaryKeyOnUuidForIssueChangesTable extends DdlChange { diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/AddPkToApplicationBranchProjs.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/AddPkToApplicationBranchProjs.java index 615b03f4144..15ac2197bea 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/AddPkToApplicationBranchProjs.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/AddPkToApplicationBranchProjs.java @@ -21,8 +21,8 @@ package org.sonar.server.platform.db.migration.version.v86; import java.sql.SQLException; import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.AddPrimaryKeyBuilder; import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v84.util.AddPrimaryKeyBuilder; public class AddPkToApplicationBranchProjs extends DdlChange { private static final String TABLE = "app_branch_project_branch"; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/AddPkToApplicationProjects.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/AddPkToApplicationProjects.java index 0aa5bb6bf23..fb96e767806 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/AddPkToApplicationProjects.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/AddPkToApplicationProjects.java @@ -21,8 +21,8 @@ package org.sonar.server.platform.db.migration.version.v86; import java.sql.SQLException; import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.AddPrimaryKeyBuilder; import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v84.util.AddPrimaryKeyBuilder; public class AddPkToApplicationProjects extends DdlChange { private static final String TABLE = "app_projects"; diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/AddPrimaryKeyToDefaultQProfiles.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/AddPrimaryKeyToDefaultQProfiles.java index 5ff6fa5e9fb..70f844b9287 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/AddPrimaryKeyToDefaultQProfiles.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/AddPrimaryKeyToDefaultQProfiles.java @@ -21,8 +21,8 @@ package org.sonar.server.platform.db.migration.version.v86; import java.sql.SQLException; import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.AddPrimaryKeyBuilder; import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v84.util.AddPrimaryKeyBuilder; public class AddPrimaryKeyToDefaultQProfiles extends DdlChange { public AddPrimaryKeyToDefaultQProfiles(Database db) { diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/DropDefaultQProfilesPk.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/DropDefaultQProfilesPk.java index f9408bbbc55..b4b2e6563bb 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/DropDefaultQProfilesPk.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/DropDefaultQProfilesPk.java @@ -21,16 +21,21 @@ package org.sonar.server.platform.db.migration.version.v86; import java.sql.SQLException; import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.sql.DropConstraintBuilder; +import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; import org.sonar.server.platform.db.migration.step.DdlChange; public class DropDefaultQProfilesPk extends DdlChange { - public DropDefaultQProfilesPk(Database db) { + private final DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator; + private static final String TABLE_NAME = "default_qprofiles"; + private static final String COLUMN_NAME = "language"; + + public DropDefaultQProfilesPk(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) { super(db); + this.dropPrimaryKeySqlGenerator = dropPrimaryKeySqlGenerator; } @Override public void execute(Context context) throws SQLException { - context.execute(new DropConstraintBuilder(getDialect()).setName("pk_default_qprofiles").setTable("default_qprofiles").build()); + context.execute(dropPrimaryKeySqlGenerator.generate(TABLE_NAME, COLUMN_NAME, false)); } } diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/DropOrganizationInRulesMetadata.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/DropOrganizationInRulesMetadata.java index a6b7e358fd5..32690e3df8d 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/DropOrganizationInRulesMetadata.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v86/DropOrganizationInRulesMetadata.java @@ -21,10 +21,10 @@ package org.sonar.server.platform.db.migration.version.v86; import java.sql.SQLException; import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.sql.AddPrimaryKeyBuilder; import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder; import org.sonar.server.platform.db.migration.sql.DropConstraintBuilder; import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v84.util.AddPrimaryKeyBuilder; public class DropOrganizationInRulesMetadata extends DdlChange { private static final String TABLE_NAME = "rules_metadata"; diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/sql/AddPrimaryKeyBuilderTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/sql/AddPrimaryKeyBuilderTest.java new file mode 100644 index 00000000000..a57cc4eadd5 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/sql/AddPrimaryKeyBuilderTest.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info 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.sql; + +import org.junit.Test; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class AddPrimaryKeyBuilderTest { + + private static final String TABLE_NAME = "issues"; + + @Test + public void generate() { + String sql = new AddPrimaryKeyBuilder(TABLE_NAME, "id").build(); + + assertThat(sql).isEqualTo("ALTER TABLE issues ADD CONSTRAINT pk_issues PRIMARY KEY (id)"); + } + + @Test + public void fail_when_table_name_is_invalid() { + assertThatThrownBy(() -> new AddPrimaryKeyBuilder("abcdefghijklmnopqrstuvwxyz", "id")) + .isInstanceOf(IllegalArgumentException.class); + } + + @Test + public void fail_when_primary_key_column_is_invalid() { + AddPrimaryKeyBuilder builder = new AddPrimaryKeyBuilder("my_table", null); + assertThatThrownBy(builder::build) + .isInstanceOf(IllegalStateException.class); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/sql/DbPrimaryKeyConstraintFinderTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/sql/DbPrimaryKeyConstraintFinderTest.java new file mode 100644 index 00000000000..dbe5b2cb795 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/sql/DbPrimaryKeyConstraintFinderTest.java @@ -0,0 +1,96 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info 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.sql; + +import java.sql.SQLException; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; +import org.sonar.db.Database; +import org.sonar.db.dialect.H2; +import org.sonar.db.dialect.MsSql; +import org.sonar.db.dialect.Oracle; +import org.sonar.db.dialect.PostgreSql; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +public class DbPrimaryKeyConstraintFinderTest { + + @Rule + public CoreDbTester db = CoreDbTester.createForSchema(DbPrimaryKeyConstraintFinderTest.class, "schema.sql"); + + private final Database dbMock = mock(Database.class); + private final DbPrimaryKeyConstraintFinder underTest = new DbPrimaryKeyConstraintFinder(dbMock); + + private static final PostgreSql POSTGRESQL = new PostgreSql(); + private static final MsSql MS_SQL = new MsSql(); + private static final Oracle ORACLE = new Oracle(); + private static final org.sonar.db.dialect.H2 H2 = new H2(); + + @Test + public void findConstraintName_constraint_exists() throws SQLException { + DbPrimaryKeyConstraintFinder underTest = new DbPrimaryKeyConstraintFinder(db.database()); + String constraintName = underTest.findConstraintName("TEST_PRIMARY_KEY"); + assertThat(constraintName).isEqualTo("PK_TEST_PRIMARY_KEY"); + } + + @Test + public void findConstraintName_constraint_not_exist() { + DbPrimaryKeyConstraintFinder underTest = new DbPrimaryKeyConstraintFinder(db.database()); + assertThatThrownBy(() -> underTest.findConstraintName("NOT_EXISTING_TABLE")) + .hasMessage("Cannot find constraint for table 'NOT_EXISTING_TABLE'") + .isInstanceOf(IllegalStateException.class); + } + + @Test + public void getDbVendorSpecificQuery_mssql() { + when(dbMock.getDialect()).thenReturn(MS_SQL); + + assertThat(underTest.getDbVendorSpecificQuery("my_table")) + .isEqualTo("SELECT name FROM sys.key_constraints WHERE type = 'PK' AND OBJECT_NAME(parent_object_id) = 'my_table'"); + } + + @Test + public void getDbVendorSpecificQuery_postgresql() { + when(dbMock.getDialect()).thenReturn(POSTGRESQL); + + assertThat(underTest.getDbVendorSpecificQuery("my_table")) + .isEqualTo("SELECT conname FROM pg_constraint WHERE conrelid = (SELECT oid FROM pg_class WHERE relname LIKE 'my_table')"); + } + + @Test + public void getDbVendorSpecificQuery_oracle() { + when(dbMock.getDialect()).thenReturn(ORACLE); + + assertThat(underTest.getDbVendorSpecificQuery("my_table")) + .isEqualTo("SELECT constraint_name FROM user_constraints WHERE table_name = UPPER('my_table') AND constraint_type='P'"); + } + + @Test + public void getDbVendorSpecificQuery_h2() { + when(dbMock.getDialect()).thenReturn(H2); + + assertThat(underTest.getDbVendorSpecificQuery("my_table")) + .isEqualTo("SELECT constraint_name FROM information_schema.constraints WHERE table_name = 'MY_TABLE' and constraint_type = 'PRIMARY KEY'"); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/sql/DropPrimaryKeySqlGeneratorTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/sql/DropPrimaryKeySqlGeneratorTest.java new file mode 100644 index 00000000000..8b1137af5ef --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/sql/DropPrimaryKeySqlGeneratorTest.java @@ -0,0 +1,129 @@ +/* + * SonarQube + * Copyright (C) 2009-2020 SonarSource SA + * mailto:info 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.sql; + +import java.sql.SQLException; +import java.util.List; +import org.junit.Test; +import org.sonar.db.Database; +import org.sonar.db.dialect.Dialect; +import org.sonar.db.dialect.H2; +import org.sonar.db.dialect.MsSql; +import org.sonar.db.dialect.Oracle; +import org.sonar.db.dialect.PostgreSql; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +public class DropPrimaryKeySqlGeneratorTest { + + private static final String TABLE_NAME = "issues"; + private static final String PK_COLUMN = "id"; + private static final String CONSTRAINT = "pk_id"; + + private static final PostgreSql POSTGRESQL = new PostgreSql(); + private static final MsSql MS_SQL = new MsSql(); + private static final Oracle ORACLE = new Oracle(); + private static final org.sonar.db.dialect.H2 H2 = new H2(); + + private final Database db = mock(Database.class); + private final DbPrimaryKeyConstraintFinder dbConstraintFinder = mock(DbPrimaryKeyConstraintFinder.class); + + private final DropPrimaryKeySqlGenerator underTest = new DropPrimaryKeySqlGenerator(db, dbConstraintFinder); + + @Test + public void generate_unknown_dialect() { + Dialect mockDialect = mock(Dialect.class); + when(mockDialect.getId()).thenReturn("unknown-db-vendor"); + when(db.getDialect()).thenReturn(mockDialect); + + assertThatThrownBy(() -> underTest.generate(TABLE_NAME, PK_COLUMN, true)) + .isInstanceOf(IllegalStateException.class); + } + + @Test + public void generate_for_postgres_sql() throws SQLException { + when(dbConstraintFinder.findConstraintName(TABLE_NAME)).thenReturn(CONSTRAINT); + when(dbConstraintFinder.getPostgresSqlSequence(TABLE_NAME, "id")).thenReturn(TABLE_NAME + "_id_seq"); + when(db.getDialect()).thenReturn(POSTGRESQL); + + List sqls = underTest.generate(TABLE_NAME, PK_COLUMN, true); + + assertThat(sqls).containsExactly("ALTER TABLE issues ALTER COLUMN id DROP DEFAULT", + "DROP SEQUENCE issues_id_seq", + "ALTER TABLE issues DROP CONSTRAINT pk_id"); + } + + @Test + public void generate_for_postgres_sql_no_seq() throws SQLException { + when(dbConstraintFinder.findConstraintName(TABLE_NAME)).thenReturn(CONSTRAINT); + when(dbConstraintFinder.getPostgresSqlSequence(TABLE_NAME, "id")).thenReturn(null); + when(db.getDialect()).thenReturn(POSTGRESQL); + + List sqls = underTest.generate(TABLE_NAME, PK_COLUMN, true); + + assertThat(sqls).containsExactly("ALTER TABLE issues ALTER COLUMN id DROP DEFAULT", + "ALTER TABLE issues DROP CONSTRAINT pk_id"); + } + + @Test + public void generate_for_ms_sql() throws SQLException { + when(dbConstraintFinder.findConstraintName(TABLE_NAME)).thenReturn(CONSTRAINT); + when(db.getDialect()).thenReturn(MS_SQL); + + List sqls = underTest.generate(TABLE_NAME, PK_COLUMN, true); + + assertThat(sqls).containsExactly("ALTER TABLE issues DROP CONSTRAINT pk_id"); + } + + @Test + public void generate_for_oracle_autogenerated_true() throws SQLException { + when(dbConstraintFinder.findConstraintName(TABLE_NAME)).thenReturn(CONSTRAINT); + when(db.getDialect()).thenReturn(ORACLE); + + List sqls = underTest.generate(TABLE_NAME, PK_COLUMN, true); + + assertThat(sqls).containsExactly("DROP TRIGGER issues_IDT", + "DROP SEQUENCE issues_SEQ", + "ALTER TABLE issues DROP CONSTRAINT pk_id DROP INDEX"); + } + + @Test + public void generate_for_oracle_autogenerated_false() throws SQLException { + when(dbConstraintFinder.findConstraintName(TABLE_NAME)).thenReturn(CONSTRAINT); + when(db.getDialect()).thenReturn(ORACLE); + + List sqls = underTest.generate(TABLE_NAME, PK_COLUMN, false); + + assertThat(sqls).containsExactly("ALTER TABLE issues DROP CONSTRAINT pk_id DROP INDEX"); + } + + @Test + public void generate_for_h2() throws SQLException { + when(dbConstraintFinder.findConstraintName(TABLE_NAME)).thenReturn(CONSTRAINT); + when(db.getDialect()).thenReturn(H2); + + List sqls = underTest.generate(TABLE_NAME, PK_COLUMN, true); + + assertThat(sqls).containsExactly("ALTER TABLE issues DROP CONSTRAINT pk_id"); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/DropIdFromComponentsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/DropIdFromComponentsTableTest.java index 86ae9b4812c..48ab42adc12 100644 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/DropIdFromComponentsTableTest.java +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/DropIdFromComponentsTableTest.java @@ -24,8 +24,8 @@ import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.version.v84.util.SqlHelper; +import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder; +import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; import static java.sql.Types.INTEGER; import static org.sonar.server.platform.db.migration.version.v83.DropIdFromComponentsTable.COLUMN_NAME; @@ -37,8 +37,8 @@ public class DropIdFromComponentsTableTest { @Rule public ExpectedException expectedException = ExpectedException.none(); - private DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(dbTester.database(), new SqlHelper(dbTester.database())); - private DropIdFromComponentsTable underTest = new DropIdFromComponentsTable(dbTester.database(), dropPrimaryKeySqlGenerator); + private final DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(dbTester.database(), new DbPrimaryKeyConstraintFinder(dbTester.database())); + private final DropIdFromComponentsTable underTest = new DropIdFromComponentsTable(dbTester.database(), dropPrimaryKeySqlGenerator); @Test public void column_has_been_dropped() throws SQLException { diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/DropPrimaryKeyOnIdColumnOfActiveRuleParametersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/DropPrimaryKeyOnIdColumnOfActiveRuleParametersTableTest.java index 4900f0fec87..f80e122edf7 100644 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/DropPrimaryKeyOnIdColumnOfActiveRuleParametersTableTest.java +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activeruleparameters/DropPrimaryKeyOnIdColumnOfActiveRuleParametersTableTest.java @@ -23,9 +23,9 @@ import java.sql.SQLException; import org.junit.Rule; import org.junit.Test; import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder; +import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; import org.sonar.server.platform.db.migration.step.MigrationStep; -import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.version.v84.util.SqlHelper; import static org.assertj.core.api.Assertions.assertThatThrownBy; @@ -35,9 +35,9 @@ public class DropPrimaryKeyOnIdColumnOfActiveRuleParametersTableTest { @Rule public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfActiveRuleParametersTableTest.class, "schema.sql"); - private DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new SqlHelper(db.database())); + private final DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new DbPrimaryKeyConstraintFinder(db.database())); - private MigrationStep underTest = new DropPrimaryKeyOnIdColumnOfActiveRuleParametersTable(db.database(), dropPrimaryKeySqlGenerator); + private final MigrationStep underTest = new DropPrimaryKeyOnIdColumnOfActiveRuleParametersTable(db.database(), dropPrimaryKeySqlGenerator); @Test public void execute() throws SQLException { diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activerules/DropPrimaryKeyOnIdColumnOfActiveRulesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activerules/DropPrimaryKeyOnIdColumnOfActiveRulesTableTest.java index a0b0b18d8ce..414f78d0659 100644 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activerules/DropPrimaryKeyOnIdColumnOfActiveRulesTableTest.java +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/activerules/DropPrimaryKeyOnIdColumnOfActiveRulesTableTest.java @@ -24,9 +24,9 @@ import java.sql.SQLException; import org.junit.Rule; import org.junit.Test; import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder; +import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.version.v84.util.SqlHelper; import static org.assertj.core.api.Assertions.assertThatThrownBy; @@ -36,9 +36,9 @@ public class DropPrimaryKeyOnIdColumnOfActiveRulesTableTest { @Rule public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfActiveRulesTableTest.class, "schema.sql"); - private DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new SqlHelper(db.database())); + private final DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new DbPrimaryKeyConstraintFinder(db.database())); - private DdlChange underTest = new DropPrimaryKeyOnIdColumnOfActiveRulesTable(db.database(), dropPrimaryKeySqlGenerator); + private final DdlChange underTest = new DropPrimaryKeyOnIdColumnOfActiveRulesTable(db.database(), dropPrimaryKeySqlGenerator); @Test public void execute() throws SQLException { diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/ceactivity/DropPrimaryKeyOnIdColumnOfCeActivityTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/ceactivity/DropPrimaryKeyOnIdColumnOfCeActivityTableTest.java index ce746d13e3d..54339d85271 100644 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/ceactivity/DropPrimaryKeyOnIdColumnOfCeActivityTableTest.java +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/ceactivity/DropPrimaryKeyOnIdColumnOfCeActivityTableTest.java @@ -23,9 +23,9 @@ import java.sql.SQLException; import org.junit.Rule; import org.junit.Test; import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder; +import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; import org.sonar.server.platform.db.migration.step.MigrationStep; -import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.version.v84.util.SqlHelper; import static org.assertj.core.api.Assertions.assertThatThrownBy; @@ -35,9 +35,9 @@ public class DropPrimaryKeyOnIdColumnOfCeActivityTableTest { @Rule public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfCeActivityTableTest.class, "schema.sql"); - private DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new SqlHelper(db.database())); + private final DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new DbPrimaryKeyConstraintFinder(db.database())); - private MigrationStep underTest = new DropPrimaryKeyOnIdColumnOfCeActivityTable(db.database(), dropPrimaryKeySqlGenerator); + private final MigrationStep underTest = new DropPrimaryKeyOnIdColumnOfCeActivityTable(db.database(), dropPrimaryKeySqlGenerator); @Test public void execute() throws SQLException { diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/cequeue/DropPrimaryKeyOnIdColumnOfCeQueueTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/cequeue/DropPrimaryKeyOnIdColumnOfCeQueueTableTest.java index 1ddcecbf85f..b4da09704d3 100644 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/cequeue/DropPrimaryKeyOnIdColumnOfCeQueueTableTest.java +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/cequeue/DropPrimaryKeyOnIdColumnOfCeQueueTableTest.java @@ -24,9 +24,9 @@ import java.sql.SQLException; import org.junit.Rule; import org.junit.Test; import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder; +import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; import org.sonar.server.platform.db.migration.step.MigrationStep; -import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.version.v84.util.SqlHelper; import static org.assertj.core.api.Assertions.assertThatThrownBy; @@ -36,9 +36,9 @@ public class DropPrimaryKeyOnIdColumnOfCeQueueTableTest { @Rule public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfCeQueueTableTest.class, "schema.sql"); - private DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new SqlHelper(db.database())); + private final DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new DbPrimaryKeyConstraintFinder(db.database())); - private MigrationStep underTest = new DropPrimaryKeyOnIdColumnOfCeQueueTable(db.database(), dropPrimaryKeySqlGenerator); + private final MigrationStep underTest = new DropPrimaryKeyOnIdColumnOfCeQueueTable(db.database(), dropPrimaryKeySqlGenerator); @Test public void execute() throws SQLException { diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/DropPrimaryKeyOnIdColumnOfDuplicationsIndexTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/DropPrimaryKeyOnIdColumnOfDuplicationsIndexTableTest.java index 3ae0004ec58..15f0da1ca29 100644 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/DropPrimaryKeyOnIdColumnOfDuplicationsIndexTableTest.java +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/duplicationsindex/DropPrimaryKeyOnIdColumnOfDuplicationsIndexTableTest.java @@ -23,9 +23,9 @@ import java.sql.SQLException; import org.junit.Rule; import org.junit.Test; import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder; +import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; import org.sonar.server.platform.db.migration.step.MigrationStep; -import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.version.v84.util.SqlHelper; import static org.assertj.core.api.Assertions.assertThatThrownBy; @@ -35,9 +35,9 @@ public class DropPrimaryKeyOnIdColumnOfDuplicationsIndexTableTest { @Rule public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfDuplicationsIndexTableTest.class, "schema.sql"); - private DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new SqlHelper(db.database())); + private final DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new DbPrimaryKeyConstraintFinder(db.database())); - private MigrationStep underTest = new DropPrimaryKeyOnIdColumnOfDuplicationsIndexTable(db.database(), dropPrimaryKeySqlGenerator); + private final MigrationStep underTest = new DropPrimaryKeyOnIdColumnOfDuplicationsIndexTable(db.database(), dropPrimaryKeySqlGenerator); @Test public void execute() throws SQLException { diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/events/DropPrimaryKeyOnIdColumnOfEventsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/events/DropPrimaryKeyOnIdColumnOfEventsTableTest.java index 4e4a7a8b0cf..8250ee07293 100644 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/events/DropPrimaryKeyOnIdColumnOfEventsTableTest.java +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/events/DropPrimaryKeyOnIdColumnOfEventsTableTest.java @@ -24,8 +24,8 @@ import java.sql.SQLException; import org.junit.Rule; import org.junit.Test; import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.version.v84.util.SqlHelper; +import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder; +import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; import static org.assertj.core.api.Assertions.assertThatThrownBy; @@ -35,9 +35,9 @@ public class DropPrimaryKeyOnIdColumnOfEventsTableTest { @Rule public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfEventsTableTest.class, "schema.sql"); - private DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new SqlHelper(db.database())); + private final DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new DbPrimaryKeyConstraintFinder(db.database())); - private DropPrimaryKeyOnIdColumnOfEventsTable underTest = new DropPrimaryKeyOnIdColumnOfEventsTable(db.database(), dropPrimaryKeySqlGenerator); + private final DropPrimaryKeyOnIdColumnOfEventsTable underTest = new DropPrimaryKeyOnIdColumnOfEventsTable(db.database(), dropPrimaryKeySqlGenerator); @Test public void execute() throws SQLException { diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/filesources/DropPrimaryKeyOnIdColumnOfFileSourcesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/filesources/DropPrimaryKeyOnIdColumnOfFileSourcesTableTest.java index b4add2d6133..46d18993a0a 100644 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/filesources/DropPrimaryKeyOnIdColumnOfFileSourcesTableTest.java +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/filesources/DropPrimaryKeyOnIdColumnOfFileSourcesTableTest.java @@ -24,9 +24,9 @@ import java.sql.SQLException; import org.junit.Rule; import org.junit.Test; import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder; +import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.version.v84.util.SqlHelper; import static org.assertj.core.api.Assertions.assertThatThrownBy; @@ -36,9 +36,9 @@ public class DropPrimaryKeyOnIdColumnOfFileSourcesTableTest { @Rule public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfFileSourcesTableTest.class, "schema.sql"); - private DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new SqlHelper(db.database())); + private final DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new DbPrimaryKeyConstraintFinder(db.database())); - private DdlChange underTest = new DropPrimaryKeyOnIdColumnOfFileSourcesTable(db.database(), dropPrimaryKeySqlGenerator); + private final DdlChange underTest = new DropPrimaryKeyOnIdColumnOfFileSourcesTable(db.database(), dropPrimaryKeySqlGenerator); @Test public void execute() throws SQLException { diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/grouproles/DropPrimaryKeyOnIdColumnOfGroupRolesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/grouproles/DropPrimaryKeyOnIdColumnOfGroupRolesTableTest.java index 670a6711c30..2f9cb01f019 100644 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/grouproles/DropPrimaryKeyOnIdColumnOfGroupRolesTableTest.java +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/grouproles/DropPrimaryKeyOnIdColumnOfGroupRolesTableTest.java @@ -24,8 +24,8 @@ import java.sql.SQLException; import org.junit.Rule; import org.junit.Test; import org.sonar.db.CoreDbTester; -import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.version.v84.util.SqlHelper; +import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder; +import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; import static org.assertj.core.api.Assertions.assertThatThrownBy; @@ -35,9 +35,9 @@ public class DropPrimaryKeyOnIdColumnOfGroupRolesTableTest { @Rule public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfGroupRolesTableTest.class, "schema.sql"); - private DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new SqlHelper(db.database())); + private final DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new DbPrimaryKeyConstraintFinder(db.database())); - private DropPrimaryKeyOnIdColumnOfGroupRolesTable underTest = new DropPrimaryKeyOnIdColumnOfGroupRolesTable(db.database(), dropPrimaryKeySqlGenerator); + private final DropPrimaryKeyOnIdColumnOfGroupRolesTable underTest = new DropPrimaryKeyOnIdColumnOfGroupRolesTable(db.database(), dropPrimaryKeySqlGenerator); @Test public void execute() throws SQLException { diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/DropPrimaryKeyOnIdColumnOfGroupsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/DropPrimaryKeyOnIdColumnOfGroupsTableTest.java index 9986f83caff..98a0a724d0d 100644 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/DropPrimaryKeyOnIdColumnOfGroupsTableTest.java +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/groups/DropPrimaryKeyOnIdColumnOfGroupsTableTest.java @@ -24,9 +24,9 @@ import java.sql.SQLException; import org.junit.Rule; import org.junit.Test; import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder; +import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.version.v84.util.SqlHelper; import static org.assertj.core.api.Assertions.assertThatThrownBy; @@ -36,9 +36,9 @@ public class DropPrimaryKeyOnIdColumnOfGroupsTableTest { @Rule public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfGroupsTableTest.class, "schema.sql"); - private DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new SqlHelper(db.database())); + private final DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new DbPrimaryKeyConstraintFinder(db.database())); - private DdlChange underTest = new DropPrimaryKeyOnIdColumnOfGroupsTable(db.database(), dropPrimaryKeySqlGenerator); + private final DdlChange underTest = new DropPrimaryKeyOnIdColumnOfGroupsTable(db.database(), dropPrimaryKeySqlGenerator); @Test public void execute() throws SQLException { diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/manualmeasures/DropPrimaryKeyOnIdColumnOfManualMeasuresTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/manualmeasures/DropPrimaryKeyOnIdColumnOfManualMeasuresTableTest.java index 556e0cf9062..33807090b25 100644 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/manualmeasures/DropPrimaryKeyOnIdColumnOfManualMeasuresTableTest.java +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/manualmeasures/DropPrimaryKeyOnIdColumnOfManualMeasuresTableTest.java @@ -23,9 +23,9 @@ import java.sql.SQLException; import org.junit.Rule; import org.junit.Test; import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder; +import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; import org.sonar.server.platform.db.migration.step.MigrationStep; -import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.version.v84.util.SqlHelper; import static org.assertj.core.api.Assertions.assertThatThrownBy; @@ -35,9 +35,9 @@ public class DropPrimaryKeyOnIdColumnOfManualMeasuresTableTest { @Rule public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfManualMeasuresTableTest.class, "schema.sql"); - private DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new SqlHelper(db.database())); + private final DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new DbPrimaryKeyConstraintFinder(db.database())); - private MigrationStep underTest = new DropPrimaryKeyOnIdColumnOfManualMeasuresTable(db.database(), dropPrimaryKeySqlGenerator); + private final MigrationStep underTest = new DropPrimaryKeyOnIdColumnOfManualMeasuresTable(db.database(), dropPrimaryKeySqlGenerator); @Test public void execute() throws SQLException { diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/DropPrimaryKeyOnIdColumnOfMetricsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/DropPrimaryKeyOnIdColumnOfMetricsTableTest.java index 35f85e4cc04..70fed865fbc 100644 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/DropPrimaryKeyOnIdColumnOfMetricsTableTest.java +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/metrics/DropPrimaryKeyOnIdColumnOfMetricsTableTest.java @@ -24,9 +24,9 @@ import java.sql.SQLException; import org.junit.Rule; import org.junit.Test; import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder; +import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.version.v84.util.SqlHelper; import static org.assertj.core.api.Assertions.assertThatThrownBy; @@ -36,9 +36,9 @@ public class DropPrimaryKeyOnIdColumnOfMetricsTableTest { @Rule public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfMetricsTableTest.class, "schema.sql"); - private DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new SqlHelper(db.database())); + private final DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new DbPrimaryKeyConstraintFinder(db.database())); - private DdlChange underTest = new DropPrimaryKeyOnIdColumnOfMetricsTable(db.database(), dropPrimaryKeySqlGenerator); + private final DdlChange underTest = new DropPrimaryKeyOnIdColumnOfMetricsTable(db.database(), dropPrimaryKeySqlGenerator); @Test public void execute() throws SQLException { diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/notifications/DropPrimaryKeyOnIdColumnOfNotificationTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/notifications/DropPrimaryKeyOnIdColumnOfNotificationTableTest.java index c0f1931c4db..ac5f71a68ad 100644 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/notifications/DropPrimaryKeyOnIdColumnOfNotificationTableTest.java +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/notifications/DropPrimaryKeyOnIdColumnOfNotificationTableTest.java @@ -23,9 +23,9 @@ import java.sql.SQLException; import org.junit.Rule; import org.junit.Test; import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder; +import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; import org.sonar.server.platform.db.migration.step.MigrationStep; -import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.version.v84.util.SqlHelper; import static org.assertj.core.api.Assertions.assertThatThrownBy; @@ -35,9 +35,9 @@ public class DropPrimaryKeyOnIdColumnOfNotificationTableTest { @Rule public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfNotificationTableTest.class, "schema.sql"); - private DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new SqlHelper(db.database())); + private final DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new DbPrimaryKeyConstraintFinder(db.database())); - private MigrationStep underTest = new DropPrimaryKeyOnIdColumnOfNotificationTable(db.database(), dropPrimaryKeySqlGenerator); + private final MigrationStep underTest = new DropPrimaryKeyOnIdColumnOfNotificationTable(db.database(), dropPrimaryKeySqlGenerator); @Test public void execute() throws SQLException { diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/DropPrimaryKeyOnIdColumnOfPermissionTemplatesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/DropPrimaryKeyOnIdColumnOfPermissionTemplatesTableTest.java index 2a95ef1e95f..7e0376d2857 100644 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/DropPrimaryKeyOnIdColumnOfPermissionTemplatesTableTest.java +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permissiontemplates/DropPrimaryKeyOnIdColumnOfPermissionTemplatesTableTest.java @@ -23,9 +23,9 @@ import java.sql.SQLException; import org.junit.Rule; import org.junit.Test; import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder; +import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; import org.sonar.server.platform.db.migration.step.MigrationStep; -import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.version.v84.util.SqlHelper; import static org.assertj.core.api.Assertions.assertThatThrownBy; @@ -35,9 +35,9 @@ public class DropPrimaryKeyOnIdColumnOfPermissionTemplatesTableTest { @Rule public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfPermissionTemplatesTableTest.class, "schema.sql"); - private DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new SqlHelper(db.database())); + private final DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new DbPrimaryKeyConstraintFinder(db.database())); - private MigrationStep underTest = new DropPrimaryKeyOnIdColumnOfPermissionTemplatesTable(db.database(), dropPrimaryKeySqlGenerator); + private final MigrationStep underTest = new DropPrimaryKeyOnIdColumnOfPermissionTemplatesTable(db.database(), dropPrimaryKeySqlGenerator); @Test public void execute() throws SQLException { diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/DropPrimaryKeyOnIdColumnOfPermTemplatesGroupsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/DropPrimaryKeyOnIdColumnOfPermTemplatesGroupsTableTest.java index 998d78102e2..aeb5fe459b3 100644 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/DropPrimaryKeyOnIdColumnOfPermTemplatesGroupsTableTest.java +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesgroups/DropPrimaryKeyOnIdColumnOfPermTemplatesGroupsTableTest.java @@ -24,9 +24,9 @@ import java.sql.SQLException; import org.junit.Rule; import org.junit.Test; import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder; +import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.version.v84.util.SqlHelper; import static org.assertj.core.api.Assertions.assertThatThrownBy; @@ -37,9 +37,9 @@ public class DropPrimaryKeyOnIdColumnOfPermTemplatesGroupsTableTest { public CoreDbTester db = CoreDbTester.createForSchema( DropPrimaryKeyOnIdColumnOfPermTemplatesGroupsTableTest.class, "schema.sql"); - private DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new SqlHelper(db.database())); + private final DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new DbPrimaryKeyConstraintFinder(db.database())); - private DdlChange underTest = new DropPrimaryKeyOnIdColumnOfPermTemplatesGroupsTable(db.database(), dropPrimaryKeySqlGenerator); + private final DdlChange underTest = new DropPrimaryKeyOnIdColumnOfPermTemplatesGroupsTable(db.database(), dropPrimaryKeySqlGenerator); @Test public void execute() throws SQLException { diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/DropPrimaryKeyOnIdColumnOfPermTemplatesUsersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/DropPrimaryKeyOnIdColumnOfPermTemplatesUsersTableTest.java index 90c54aceca4..7e8e2cde493 100644 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/DropPrimaryKeyOnIdColumnOfPermTemplatesUsersTableTest.java +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtemplatesusers/DropPrimaryKeyOnIdColumnOfPermTemplatesUsersTableTest.java @@ -24,9 +24,9 @@ import java.sql.SQLException; import org.junit.Rule; import org.junit.Test; import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder; +import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.version.v84.util.SqlHelper; import static org.assertj.core.api.Assertions.assertThatThrownBy; @@ -37,9 +37,9 @@ public class DropPrimaryKeyOnIdColumnOfPermTemplatesUsersTableTest { public CoreDbTester db = CoreDbTester.createForSchema( DropPrimaryKeyOnIdColumnOfPermTemplatesUsersTableTest.class, "schema.sql"); - private DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new SqlHelper(db.database())); + private final DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new DbPrimaryKeyConstraintFinder(db.database())); - private DdlChange underTest = new DropPrimaryKeyOnIdColumnOfPermTemplatesUsersTable(db.database(), dropPrimaryKeySqlGenerator); + private final DdlChange underTest = new DropPrimaryKeyOnIdColumnOfPermTemplatesUsersTable(db.database(), dropPrimaryKeySqlGenerator); @Test public void execute() throws SQLException { diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/DropPrimaryKeyOnIdColumnOfPermTplCharacteristicsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/DropPrimaryKeyOnIdColumnOfPermTplCharacteristicsTableTest.java index 0a11ab48f98..fa53ae43288 100644 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/DropPrimaryKeyOnIdColumnOfPermTplCharacteristicsTableTest.java +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/permtplcharacteristics/DropPrimaryKeyOnIdColumnOfPermTplCharacteristicsTableTest.java @@ -24,9 +24,9 @@ import java.sql.SQLException; import org.junit.Rule; import org.junit.Test; import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder; +import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.version.v84.util.SqlHelper; import static org.assertj.core.api.Assertions.assertThatThrownBy; @@ -37,9 +37,9 @@ public class DropPrimaryKeyOnIdColumnOfPermTplCharacteristicsTableTest { public CoreDbTester db = CoreDbTester.createForSchema( DropPrimaryKeyOnIdColumnOfPermTplCharacteristicsTableTest.class, "schema.sql"); - private DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new SqlHelper(db.database())); + private final DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new DbPrimaryKeyConstraintFinder(db.database())); - private DdlChange underTest = new DropPrimaryKeyOnIdColumnOfPermTplCharacteristicsTable(db.database(), dropPrimaryKeySqlGenerator); + private final DdlChange underTest = new DropPrimaryKeyOnIdColumnOfPermTplCharacteristicsTable(db.database(), dropPrimaryKeySqlGenerator); @Test public void execute() throws SQLException { diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/DropPrimaryKeyOnIdColumnOfProjectMeasuresTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/DropPrimaryKeyOnIdColumnOfProjectMeasuresTableTest.java index b8f895d6842..cbe1e4b2b7f 100644 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/DropPrimaryKeyOnIdColumnOfProjectMeasuresTableTest.java +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/projectmeasures/DropPrimaryKeyOnIdColumnOfProjectMeasuresTableTest.java @@ -23,9 +23,9 @@ import java.sql.SQLException; import org.junit.Rule; import org.junit.Test; import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder; +import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; import org.sonar.server.platform.db.migration.step.MigrationStep; -import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.version.v84.util.SqlHelper; import static org.assertj.core.api.Assertions.assertThatThrownBy; @@ -35,9 +35,9 @@ public class DropPrimaryKeyOnIdColumnOfProjectMeasuresTableTest { @Rule public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfProjectMeasuresTableTest.class, "schema.sql"); - private DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new SqlHelper(db.database())); + private final DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new DbPrimaryKeyConstraintFinder(db.database())); - private MigrationStep underTest = new DropPrimaryKeyOnIdColumnOfProjectMeasuresTable(db.database(), dropPrimaryKeySqlGenerator); + private final MigrationStep underTest = new DropPrimaryKeyOnIdColumnOfProjectMeasuresTable(db.database(), dropPrimaryKeySqlGenerator); @Test public void execute() throws SQLException { diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/DropPrimaryKeyOnIdColumnOfProjectQProfilesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/DropPrimaryKeyOnIdColumnOfProjectQProfilesTableTest.java index 9e464b57dd0..4e409418824 100644 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/DropPrimaryKeyOnIdColumnOfProjectQProfilesTableTest.java +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/projectqprofiles/DropPrimaryKeyOnIdColumnOfProjectQProfilesTableTest.java @@ -23,9 +23,9 @@ import java.sql.SQLException; import org.junit.Rule; import org.junit.Test; import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder; +import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.version.v84.util.SqlHelper; import static org.assertj.core.api.Assertions.assertThatThrownBy; @@ -34,9 +34,9 @@ public class DropPrimaryKeyOnIdColumnOfProjectQProfilesTableTest { @Rule public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfProjectQProfilesTableTest.class, "schema.sql"); - private DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new SqlHelper(db.database())); + private final DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new DbPrimaryKeyConstraintFinder(db.database())); - private DdlChange underTest = new DropPrimaryKeyOnIdColumnOfProjectQProfilesTable(db.database(), dropPrimaryKeySqlGenerator); + private final DdlChange underTest = new DropPrimaryKeyOnIdColumnOfProjectQProfilesTable(db.database(), dropPrimaryKeySqlGenerator); @Test public void execute() throws SQLException { diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/properties/DropPrimaryKeyOnIdColumnOfPropertiesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/properties/DropPrimaryKeyOnIdColumnOfPropertiesTableTest.java index 0e3b583bec2..5d33702c092 100644 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/properties/DropPrimaryKeyOnIdColumnOfPropertiesTableTest.java +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/properties/DropPrimaryKeyOnIdColumnOfPropertiesTableTest.java @@ -23,9 +23,9 @@ import java.sql.SQLException; import org.junit.Rule; import org.junit.Test; import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder; +import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; import org.sonar.server.platform.db.migration.step.MigrationStep; -import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.version.v84.util.SqlHelper; import static org.assertj.core.api.Assertions.assertThatThrownBy; @@ -35,9 +35,9 @@ public class DropPrimaryKeyOnIdColumnOfPropertiesTableTest { @Rule public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfPropertiesTableTest.class, "schema.sql"); - private DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new SqlHelper(db.database())); + private final DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new DbPrimaryKeyConstraintFinder(db.database())); - private MigrationStep underTest = new DropPrimaryKeyOnIdColumnOfPropertiesTable(db.database(), dropPrimaryKeySqlGenerator); + private final MigrationStep underTest = new DropPrimaryKeyOnIdColumnOfPropertiesTable(db.database(), dropPrimaryKeySqlGenerator); @Test public void execute() throws SQLException { diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/DropPrimaryKeyOnIdColumnOfQualityGateConditionsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/DropPrimaryKeyOnIdColumnOfQualityGateConditionsTableTest.java index 1b84fde48e5..615a0cf37d4 100644 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/DropPrimaryKeyOnIdColumnOfQualityGateConditionsTableTest.java +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygateconditions/DropPrimaryKeyOnIdColumnOfQualityGateConditionsTableTest.java @@ -24,9 +24,9 @@ import java.sql.SQLException; import org.junit.Rule; import org.junit.Test; import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder; +import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.version.v84.util.SqlHelper; import static org.assertj.core.api.Assertions.assertThatThrownBy; @@ -36,9 +36,9 @@ public class DropPrimaryKeyOnIdColumnOfQualityGateConditionsTableTest { @Rule public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfQualityGateConditionsTableTest.class, "schema.sql"); - private DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new SqlHelper(db.database())); + private final DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new DbPrimaryKeyConstraintFinder(db.database())); - private DdlChange underTest = new DropPrimaryKeyOnIdColumnOfQualityGateConditionsTable(db.database(), dropPrimaryKeySqlGenerator); + private final DdlChange underTest = new DropPrimaryKeyOnIdColumnOfQualityGateConditionsTable(db.database(), dropPrimaryKeySqlGenerator); @Test public void execute() throws SQLException { diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropPrimaryKeyOnIdColumnOfQGatesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropPrimaryKeyOnIdColumnOfQGatesTableTest.java index 3b47c7cf239..ab6a98b54ee 100644 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropPrimaryKeyOnIdColumnOfQGatesTableTest.java +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/qualitygates/DropPrimaryKeyOnIdColumnOfQGatesTableTest.java @@ -23,9 +23,9 @@ import java.sql.SQLException; import org.junit.Rule; import org.junit.Test; import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder; +import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; import org.sonar.server.platform.db.migration.step.MigrationStep; -import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.version.v84.util.SqlHelper; import static org.assertj.core.api.Assertions.assertThatThrownBy; @@ -36,9 +36,9 @@ public class DropPrimaryKeyOnIdColumnOfQGatesTableTest { @Rule public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfQGatesTableTest.class, "schema.sql"); - private DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new SqlHelper(db.database())); + private final DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new DbPrimaryKeyConstraintFinder(db.database())); - private MigrationStep underTest = new DropPrimaryKeyOnIdColumnOfQGatesTable(db.database(), dropPrimaryKeySqlGenerator); + private final MigrationStep underTest = new DropPrimaryKeyOnIdColumnOfQGatesTable(db.database(), dropPrimaryKeySqlGenerator); @Test public void execute() throws SQLException { diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/DropPrimaryKeyOnIdColumnOfRulesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/DropPrimaryKeyOnIdColumnOfRulesTableTest.java index b54648c5e6d..595018573fa 100644 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/DropPrimaryKeyOnIdColumnOfRulesTableTest.java +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/DropPrimaryKeyOnIdColumnOfRulesTableTest.java @@ -23,9 +23,9 @@ import java.sql.SQLException; import org.junit.Rule; import org.junit.Test; import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder; +import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; import org.sonar.server.platform.db.migration.step.MigrationStep; -import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.version.v84.util.SqlHelper; import static org.assertj.core.api.Assertions.assertThatThrownBy; @@ -34,8 +34,8 @@ public class DropPrimaryKeyOnIdColumnOfRulesTableTest { @Rule public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfRulesTableTest.class, "schema.sql"); - private MigrationStep underTest = new DropPrimaryKeyOnIdColumnOfRulesTable(db.database(), - new DropPrimaryKeySqlGenerator(db.database(), new SqlHelper(db.database()))); + private final MigrationStep underTest = new DropPrimaryKeyOnIdColumnOfRulesTable(db.database(), + new DropPrimaryKeySqlGenerator(db.database(), new DbPrimaryKeyConstraintFinder(db.database()))); @Test public void execute() throws SQLException { diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/DropPrimaryKeyOnIdColumnOfRulesMetadataTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/DropPrimaryKeyOnIdColumnOfRulesMetadataTableTest.java index 371079a6713..031a8474b73 100644 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/DropPrimaryKeyOnIdColumnOfRulesMetadataTableTest.java +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rules/rulesmetadata/DropPrimaryKeyOnIdColumnOfRulesMetadataTableTest.java @@ -23,9 +23,9 @@ import java.sql.SQLException; import org.junit.Rule; import org.junit.Test; import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder; +import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; import org.sonar.server.platform.db.migration.step.MigrationStep; -import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.version.v84.util.SqlHelper; import static org.assertj.core.api.Assertions.assertThatThrownBy; @@ -34,8 +34,8 @@ public class DropPrimaryKeyOnIdColumnOfRulesMetadataTableTest { @Rule public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfRulesMetadataTableTest.class, "schema.sql"); - private MigrationStep underTest = new DropPrimaryKeyOnIdColumnOfRulesMetadataTable(db.database(), - new DropPrimaryKeySqlGenerator(db.database(), new SqlHelper(db.database()))); + private final MigrationStep underTest = new DropPrimaryKeyOnIdColumnOfRulesMetadataTable(db.database(), + new DropPrimaryKeySqlGenerator(db.database(), new DbPrimaryKeyConstraintFinder(db.database()))); @Test public void execute() throws SQLException { diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/DropPrimaryKeyOnIdColumnOfRulesParametersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/DropPrimaryKeyOnIdColumnOfRulesParametersTableTest.java index 6cf0cdab750..86eb444fdb3 100644 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/DropPrimaryKeyOnIdColumnOfRulesParametersTableTest.java +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesparameters/DropPrimaryKeyOnIdColumnOfRulesParametersTableTest.java @@ -23,9 +23,9 @@ import java.sql.SQLException; import org.junit.Rule; import org.junit.Test; import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder; +import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; import org.sonar.server.platform.db.migration.step.MigrationStep; -import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.version.v84.util.SqlHelper; import static org.assertj.core.api.Assertions.assertThatThrownBy; @@ -35,9 +35,9 @@ public class DropPrimaryKeyOnIdColumnOfRulesParametersTableTest { @Rule public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfRulesParametersTableTest.class, "schema.sql"); - private DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new SqlHelper(db.database())); + private final DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new DbPrimaryKeyConstraintFinder(db.database())); - private MigrationStep underTest = new DropPrimaryKeyOnIdColumnOfRulesParametersTable(db.database(), dropPrimaryKeySqlGenerator); + private final MigrationStep underTest = new DropPrimaryKeyOnIdColumnOfRulesParametersTable(db.database(), dropPrimaryKeySqlGenerator); @Test public void execute() throws SQLException { diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/DropPrimaryKeyOnIdColumnOfRulesProfilesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/DropPrimaryKeyOnIdColumnOfRulesProfilesTableTest.java index ad2dbeed17d..55c9f279b30 100644 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/DropPrimaryKeyOnIdColumnOfRulesProfilesTableTest.java +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/rulesprofiles/DropPrimaryKeyOnIdColumnOfRulesProfilesTableTest.java @@ -23,9 +23,9 @@ import java.sql.SQLException; import org.junit.Rule; import org.junit.Test; import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder; +import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.version.v84.util.SqlHelper; import static org.assertj.core.api.Assertions.assertThatThrownBy; @@ -34,9 +34,9 @@ public class DropPrimaryKeyOnIdColumnOfRulesProfilesTableTest { @Rule public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfRulesProfilesTableTest.class, "schema.sql"); - private DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new SqlHelper(db.database())); + private final DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new DbPrimaryKeyConstraintFinder(db.database())); - private DdlChange underTest = new DropPrimaryKeyOnIdColumnOfRulesProfilesTable(db.database(), dropPrimaryKeySqlGenerator); + private final DdlChange underTest = new DropPrimaryKeyOnIdColumnOfRulesProfilesTable(db.database(), dropPrimaryKeySqlGenerator); @Test public void execute() throws SQLException { diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/snapshots/DropPrimaryKeyOnIdColumnOfSnapshotsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/snapshots/DropPrimaryKeyOnIdColumnOfSnapshotsTableTest.java index d2cb5ad5419..8b18972eaec 100644 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/snapshots/DropPrimaryKeyOnIdColumnOfSnapshotsTableTest.java +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/snapshots/DropPrimaryKeyOnIdColumnOfSnapshotsTableTest.java @@ -24,9 +24,9 @@ import java.sql.SQLException; import org.junit.Rule; import org.junit.Test; import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder; +import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; import org.sonar.server.platform.db.migration.version.v84.snapshots.issues.DropPrimaryKeyOnIdColumnOfSnapshotsTable; -import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.version.v84.util.SqlHelper; import static org.assertj.core.api.Assertions.assertThatThrownBy; @@ -36,9 +36,9 @@ public class DropPrimaryKeyOnIdColumnOfSnapshotsTableTest { @Rule public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfSnapshotsTableTest.class, "schema.sql"); - private DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new SqlHelper(db.database())); + private final DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new DbPrimaryKeyConstraintFinder(db.database())); - private DropPrimaryKeyOnIdColumnOfSnapshotsTable underTest = new DropPrimaryKeyOnIdColumnOfSnapshotsTable(db.database(), dropPrimaryKeySqlGenerator); + private final DropPrimaryKeyOnIdColumnOfSnapshotsTable underTest = new DropPrimaryKeyOnIdColumnOfSnapshotsTable(db.database(), dropPrimaryKeySqlGenerator); @Test public void execute() throws SQLException { diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/DropPrimaryKeyOnIdColumnOfUsersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/DropPrimaryKeyOnIdColumnOfUsersTableTest.java index dc53112e842..d7e0c428651 100644 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/DropPrimaryKeyOnIdColumnOfUsersTableTest.java +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/DropPrimaryKeyOnIdColumnOfUsersTableTest.java @@ -23,9 +23,9 @@ import java.sql.SQLException; import org.junit.Rule; import org.junit.Test; import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder; +import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.version.v84.util.SqlHelper; import static org.assertj.core.api.Assertions.assertThatThrownBy; @@ -34,9 +34,9 @@ public class DropPrimaryKeyOnIdColumnOfUsersTableTest { @Rule public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfUsersTableTest.class, "schema.sql"); - private DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new SqlHelper(db.database())); + private final DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new DbPrimaryKeyConstraintFinder(db.database())); - private DdlChange underTest = new DropPrimaryKeyOnIdColumnOfUsersTable(db.database(), dropPrimaryKeySqlGenerator); + private final DdlChange underTest = new DropPrimaryKeyOnIdColumnOfUsersTable(db.database(), dropPrimaryKeySqlGenerator); @Test public void execute() throws SQLException { diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/DropPrimaryKeyOnUserIdAndOrganizationUuidOfOrganizationMembersTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/DropPrimaryKeyOnUserIdAndOrganizationUuidOfOrganizationMembersTableTest.java index 4019839d54e..3ba6bb952eb 100644 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/DropPrimaryKeyOnUserIdAndOrganizationUuidOfOrganizationMembersTableTest.java +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/users/fk/organizationmembers/DropPrimaryKeyOnUserIdAndOrganizationUuidOfOrganizationMembersTableTest.java @@ -23,9 +23,9 @@ import java.sql.SQLException; import org.junit.Rule; import org.junit.Test; import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder; +import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; import org.sonar.server.platform.db.migration.step.DdlChange; -import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.version.v84.util.SqlHelper; import static org.assertj.core.api.Assertions.assertThatThrownBy; @@ -34,9 +34,9 @@ public class DropPrimaryKeyOnUserIdAndOrganizationUuidOfOrganizationMembersTable @Rule public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnUserIdAndOrganizationUuidOfOrganizationMembersTableTest.class, "schema.sql"); - private DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new SqlHelper(db.database())); + private final DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new DbPrimaryKeyConstraintFinder(db.database())); - private DdlChange underTest = new DropPrimaryKeyOnUserIdAndOrganizationUuidOfOrganizationMembersTable(db.database(), dropPrimaryKeySqlGenerator); + private final DdlChange underTest = new DropPrimaryKeyOnUserIdAndOrganizationUuidOfOrganizationMembersTable(db.database(), dropPrimaryKeySqlGenerator); @Test public void execute() throws SQLException { diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/usertokens/DropPrimaryKeyOnIdColumnOfUserTokensTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/usertokens/DropPrimaryKeyOnIdColumnOfUserTokensTableTest.java index 519e7c9140e..2491c4bee1b 100644 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/usertokens/DropPrimaryKeyOnIdColumnOfUserTokensTableTest.java +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/usertokens/DropPrimaryKeyOnIdColumnOfUserTokensTableTest.java @@ -23,9 +23,9 @@ import java.sql.SQLException; import org.junit.Rule; import org.junit.Test; import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder; +import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; import org.sonar.server.platform.db.migration.step.MigrationStep; -import org.sonar.server.platform.db.migration.version.v84.util.DropPrimaryKeySqlGenerator; -import org.sonar.server.platform.db.migration.version.v84.util.SqlHelper; import static org.assertj.core.api.Assertions.assertThatThrownBy; @@ -35,9 +35,9 @@ public class DropPrimaryKeyOnIdColumnOfUserTokensTableTest { @Rule public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfUserTokensTableTest.class, "schema.sql"); - private DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new SqlHelper(db.database())); + private final DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new DbPrimaryKeyConstraintFinder(db.database())); - private MigrationStep underTest = new DropPrimaryKeyOnIdColumnOfUserTokensTable(db.database(), dropPrimaryKeySqlGenerator); + private final MigrationStep underTest = new DropPrimaryKeyOnIdColumnOfUserTokensTable(db.database(), dropPrimaryKeySqlGenerator); @Test public void execute() throws SQLException { diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/util/AddPrimaryKeyBuilderTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/util/AddPrimaryKeyBuilderTest.java deleted file mode 100644 index ef69661255d..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/util/AddPrimaryKeyBuilderTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info 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.v84.util; - -import org.junit.Test; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class AddPrimaryKeyBuilderTest { - - private static final String TABLE_NAME = "issues"; - - @Test - public void generate() { - String sql = new AddPrimaryKeyBuilder(TABLE_NAME, "id").build(); - - assertThat(sql).isEqualTo("ALTER TABLE issues ADD CONSTRAINT pk_issues PRIMARY KEY (id)"); - } - - @Test - public void fail_when_table_name_is_invalid() { - assertThatThrownBy(() -> new AddPrimaryKeyBuilder("abcdefghijklmnopqrstuvwxyz", "id").build()) - .isInstanceOf(IllegalArgumentException.class); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/util/DropPrimaryKeySqlGeneratorTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/util/DropPrimaryKeySqlGeneratorTest.java deleted file mode 100644 index c18c8ef748a..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/util/DropPrimaryKeySqlGeneratorTest.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2020 SonarSource SA - * mailto:info 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.v84.util; - -import java.sql.SQLException; -import java.util.List; -import org.junit.Test; -import org.sonar.db.Database; -import org.sonar.db.dialect.H2; -import org.sonar.db.dialect.MsSql; -import org.sonar.db.dialect.Oracle; -import org.sonar.db.dialect.PostgreSql; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -public class DropPrimaryKeySqlGeneratorTest { - - private static final String TABLE_NAME = "issues"; - private static final String PK_COLUMN = "id"; - private static final String CONSTRAINT = "pk_id"; - - private static final PostgreSql POSTGRESQL = new PostgreSql(); - private static final MsSql MS_SQL = new MsSql(); - private static final Oracle ORACLE = new Oracle(); - private static final org.sonar.db.dialect.H2 H2 = new H2(); - - private Database db = mock(Database.class); - private SqlHelper sqlHelper = mock(SqlHelper.class); - - private DropPrimaryKeySqlGenerator underTest = new DropPrimaryKeySqlGenerator(db, sqlHelper); - - @Test - public void generate_for_postgres_sql() throws SQLException { - when(sqlHelper.getPostgresSqlConstraint(TABLE_NAME)).thenReturn(CONSTRAINT); - when(sqlHelper.getPostgresSqlSequence(TABLE_NAME, "id")).thenReturn(TABLE_NAME + "_id_seq"); - when(db.getDialect()).thenReturn(POSTGRESQL); - - List sqls = underTest.generate(TABLE_NAME, PK_COLUMN, true); - - assertThat(sqls).containsExactly("ALTER TABLE issues ALTER COLUMN id DROP DEFAULT", - "DROP SEQUENCE issues_id_seq", - "ALTER TABLE issues DROP CONSTRAINT pk_id"); - } - - @Test - public void generate_for_ms_sql() throws SQLException { - when(sqlHelper.getMssqlConstraint(TABLE_NAME)).thenReturn(CONSTRAINT); - when(db.getDialect()).thenReturn(MS_SQL); - - List sqls = underTest.generate(TABLE_NAME, PK_COLUMN, true); - - assertThat(sqls).containsExactly("ALTER TABLE issues DROP CONSTRAINT pk_id"); - } - - @Test - public void generate_for_oracle() throws SQLException { - when(sqlHelper.getOracleConstraint(TABLE_NAME)).thenReturn(CONSTRAINT); - when(db.getDialect()).thenReturn(ORACLE); - - List sqls = underTest.generate(TABLE_NAME, PK_COLUMN, true); - - assertThat(sqls).containsExactly("DROP TRIGGER issues_IDT", - "DROP SEQUENCE issues_SEQ", - "ALTER TABLE issues DROP CONSTRAINT pk_id DROP INDEX"); - } - - @Test - public void generate_for_h2() throws SQLException { - when(sqlHelper.getH2Constraint(TABLE_NAME)).thenReturn(CONSTRAINT); - when(db.getDialect()).thenReturn(H2); - - List sqls = underTest.generate(TABLE_NAME, PK_COLUMN, true); - - assertThat(sqls).containsExactly("ALTER TABLE issues DROP CONSTRAINT pk_id", - "ALTER TABLE issues ALTER COLUMN id INTEGER NOT NULL"); - } -} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/DropDefaultQProfilesPkTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/DropDefaultQProfilesPkTest.java index 45b34c2ca5d..aef06c6537b 100644 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/DropDefaultQProfilesPkTest.java +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v86/DropDefaultQProfilesPkTest.java @@ -23,13 +23,15 @@ import java.sql.SQLException; import org.junit.Rule; import org.junit.Test; import org.sonar.db.CoreDbTester; +import org.sonar.server.platform.db.migration.sql.DbPrimaryKeyConstraintFinder; +import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator; import org.sonar.server.platform.db.migration.step.MigrationStep; public class DropDefaultQProfilesPkTest { @Rule public CoreDbTester db = CoreDbTester.createForSchema(DropDefaultQProfilesPkTest.class, "schema.sql"); - private MigrationStep underTest = new DropDefaultQProfilesPk(db.database()); + private final MigrationStep underTest = new DropDefaultQProfilesPk(db.database(), new DropPrimaryKeySqlGenerator(db.database(), new DbPrimaryKeyConstraintFinder(db.database()))); @Test public void execute() throws SQLException { diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/sql/DbPrimaryKeyConstraintFinderTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/sql/DbPrimaryKeyConstraintFinderTest/schema.sql new file mode 100644 index 00000000000..bb4ba642b4a --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/sql/DbPrimaryKeyConstraintFinderTest/schema.sql @@ -0,0 +1,4 @@ +CREATE TABLE "TEST_PRIMARY_KEY"( + "UUID" VARCHAR(40) NOT NULL +); +ALTER TABLE "TEST_PRIMARY_KEY" ADD CONSTRAINT "PK_TEST_PRIMARY_KEY" PRIMARY KEY("UUID");