]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-13985 Drop associated index with primary key on Oracle DB
authorJacek <jacek.poreda@sonarsource.com>
Tue, 13 Oct 2020 11:11:24 +0000 (13:11 +0200)
committerMalena Ebert <malena.ebert@sonarsource.com>
Fri, 23 Oct 2020 09:31:01 +0000 (11:31 +0200)
(cherry picked from commit 75d4d26ef50c17c41a6de991970eded9fa916435)

server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v84/util/DropPrimaryKeySqlGenerator.java
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/util/DropPrimaryKeySqlGeneratorTest.java

index 51424addd8328e495013b38c2a42e7a06212a997..81a317fa09a4f13623e67846c92c483c0e8736a4 100644 (file)
@@ -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;
   }
 
index 5569ee18d658c4e73875f04bd9c3c28e0ef52047..c18c8ef748a4d1c7e7aced617a40535ad535972e 100644 (file)
@@ -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