From c0d0fcd0aba4fb75e6077768e07c1bef481ad9d2 Mon Sep 17 00:00:00 2001 From: Steve Marion Date: Thu, 23 Feb 2023 11:46:40 +0100 Subject: [PATCH] [SONAR-18502] add test for index drop change explicitely test the case where actual index is different and longer than authorized --- .../DropIndexProjectsModuleUuidInComponentsTest.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v100/DropIndexProjectsModuleUuidInComponentsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v100/DropIndexProjectsModuleUuidInComponentsTest.java index 663b1ba237f..9824d61eeb5 100644 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v100/DropIndexProjectsModuleUuidInComponentsTest.java +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v100/DropIndexProjectsModuleUuidInComponentsTest.java @@ -41,6 +41,16 @@ public class DropIndexProjectsModuleUuidInComponentsTest { db.assertIndexDoesNotExist(TABLE_NAME, INDEX_NAME); } + @Test + public void execute_whenIndexNameWithPrefix_shouldStillDelete() throws SQLException { + String alteredIndexName = "idx_1234567891345678916456789_" + INDEX_NAME; + db.executeUpdateSql(String.format("ALTER INDEX %s RENAME TO %s;", INDEX_NAME, alteredIndexName)); + db.assertIndexDoesNotExist(TABLE_NAME, INDEX_NAME); + db.assertIndex(TABLE_NAME, alteredIndexName, COLUMN_NAME); + underTest.execute(); + db.assertIndexDoesNotExist(TABLE_NAME, alteredIndexName); + } + @Test public void migration_is_reentrant() throws SQLException { db.assertIndex(TABLE_NAME, INDEX_NAME, COLUMN_NAME); -- 2.39.5