From: Jacek Date: Tue, 13 Oct 2020 11:11:24 +0000 (+0200) Subject: SONAR-13985 Drop associated index with primary key on Oracle DB X-Git-Tag: 8.5.1.38104~5 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=99764894f7025d039e45ce07f0a4492b1645cc4f;p=sonarqube.git SONAR-13985 Drop associated index with primary key on Oracle DB (cherry picked from commit 75d4d26ef50c17c41a6de991970eded9fa916435) --- 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 index 51424addd83..81a317fa09a 100644 --- 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 @@ -82,7 +82,8 @@ public class DropPrimaryKeySqlGenerator { statements.add(format("DROP SEQUENCE %s_SEQ", tableName)); } - statements.add(format(GENERIC_DROP_CONSTRAINT_STATEMENT, tableName, constraintName)); + // '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; } 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 index 5569ee18d65..c18c8ef748a 100644 --- 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 @@ -80,7 +80,7 @@ public class DropPrimaryKeySqlGeneratorTest { assertThat(sqls).containsExactly("DROP TRIGGER issues_IDT", "DROP SEQUENCE issues_SEQ", - "ALTER TABLE issues DROP CONSTRAINT pk_id"); + "ALTER TABLE issues DROP CONSTRAINT pk_id DROP INDEX"); } @Test