aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-db-migration
diff options
context:
space:
mode:
authorDuarte Meneses <duarte.meneses@sonarsource.com>2021-03-02 15:29:19 -0600
committersonartech <sonartech@sonarsource.com>2021-03-08 20:07:54 +0000
commit77939e95492a4c7840114c95c8a38347526c98c5 (patch)
tree13f2d35b929aac2ecd589eb848f2451deba42dd4 /server/sonar-db-migration
parent8f61434c75d464682f2ca04951fd02b212070781 (diff)
downloadsonarqube-77939e95492a4c7840114c95c8a38347526c98c5.tar.gz
sonarqube-77939e95492a4c7840114c95c8a38347526c98c5.zip
SONAR-14541 Migration 4207 fails if the PK constraint name is unexpected
Diffstat (limited to 'server/sonar-db-migration')
-rw-r--r--server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v87/DropAlmAppInstallsTable.java8
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v87/DropAlmAppInstallsTableTest.java5
2 files changed, 10 insertions, 3 deletions
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v87/DropAlmAppInstallsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v87/DropAlmAppInstallsTable.java
index a6869ced1ab..ff8396c103f 100644
--- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v87/DropAlmAppInstallsTable.java
+++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v87/DropAlmAppInstallsTable.java
@@ -20,22 +20,26 @@
package org.sonar.server.platform.db.migration.version.v87;
import java.sql.SQLException;
+import java.util.Arrays;
import org.sonar.db.Database;
import org.sonar.server.platform.db.migration.sql.DropConstraintBuilder;
import org.sonar.server.platform.db.migration.sql.DropIndexBuilder;
+import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator;
import org.sonar.server.platform.db.migration.sql.DropTableBuilder;
import org.sonar.server.platform.db.migration.step.DdlChange;
public class DropAlmAppInstallsTable extends DdlChange {
private static final String TABLE_NAME = "alm_app_installs";
+ private final DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator;
- public DropAlmAppInstallsTable(Database db) {
+ public DropAlmAppInstallsTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) {
super(db);
+ this.dropPrimaryKeySqlGenerator = dropPrimaryKeySqlGenerator;
}
@Override
public void execute(Context context) throws SQLException {
- context.execute(new DropConstraintBuilder(getDialect()).setTable(TABLE_NAME).setName("pk_alm_app_installs").build());
+ context.execute(dropPrimaryKeySqlGenerator.generate(TABLE_NAME, "uuid", false));
context.execute(new DropIndexBuilder(getDialect()).setTable(TABLE_NAME).setName("alm_app_installs_owner").build());
context.execute(new DropIndexBuilder(getDialect()).setTable(TABLE_NAME).setName("alm_app_installs_install").build());
context.execute(new DropIndexBuilder(getDialect()).setTable(TABLE_NAME).setName("alm_app_installs_external_id").build());
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v87/DropAlmAppInstallsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v87/DropAlmAppInstallsTableTest.java
index 1cf574f0def..768ab0a3f8f 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v87/DropAlmAppInstallsTableTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v87/DropAlmAppInstallsTableTest.java
@@ -23,6 +23,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.sql.DbPrimaryKeyConstraintFinder;
+import org.sonar.server.platform.db.migration.sql.DropPrimaryKeySqlGenerator;
import org.sonar.server.platform.db.migration.step.MigrationStep;
public class DropAlmAppInstallsTableTest {
@@ -30,8 +32,9 @@ public class DropAlmAppInstallsTableTest {
@Rule
public CoreDbTester db = CoreDbTester.createForSchema(DropAlmAppInstallsTableTest.class, "schema.sql");
+ private final DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new DbPrimaryKeyConstraintFinder(db.database()));
- private MigrationStep underTest = new DropAlmAppInstallsTable(db.database());
+ private MigrationStep underTest = new DropAlmAppInstallsTable(db.database(), dropPrimaryKeySqlGenerator);
@Test
public void execute() throws SQLException {