From: Pierre Date: Wed, 30 Aug 2023 14:52:08 +0000 (+0200) Subject: SONAR-20058 simplify upgrade to 10.2 by removing index creation that is deleted later X-Git-Tag: 10.2.0.77647~12 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=7b88e39a4f48f8d2b4ca053c54c15fd4970b67ae;p=sonarqube.git SONAR-20058 simplify upgrade to 10.2 by removing index creation that is deleted later --- diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v102/CreateIndexProjectUuidInWebhookDeliveries.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v102/CreateIndexProjectUuidInWebhookDeliveries.java deleted file mode 100644 index cadc8fa0869..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v102/CreateIndexProjectUuidInWebhookDeliveries.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2023 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.v102; - -import org.sonar.db.Database; -import org.sonar.server.platform.db.migration.step.CreateIndexOnColumn; - -public class CreateIndexProjectUuidInWebhookDeliveries extends CreateIndexOnColumn { - - private static final String TABLE_NAME = "webhook_deliveries"; - private static final String COLUMN_NAME = "project_uuid"; - - public CreateIndexProjectUuidInWebhookDeliveries(Database db) { - super(db, TABLE_NAME, COLUMN_NAME, false); - } - - /** - * There is a limit of 30 characters for index name, that's why this one has a different name - */ - @Override - public String newIndexName() { - return "wd_" + COLUMN_NAME; - } -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v102/DbVersion102.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v102/DbVersion102.java index 66b80b60b0b..d676fdd91c3 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v102/DbVersion102.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v102/DbVersion102.java @@ -65,7 +65,6 @@ public class DbVersion102 implements DbVersion { .add(10_2_015, "Drop index 'component_uuid' in 'webhook_deliveries' table", DropIndexComponentUuidInWebhookDeliveries.class) .add(10_2_016, "Rename 'component_uuid' in 'webhook_deliveries' table to 'project_uuid'", RenameComponentUuidInWebhookDeliveries.class) - .add(10_2_017, "Create index 'webhook_deliveries_project_uuid' in 'webhook_deliveries' table", CreateIndexProjectUuidInWebhookDeliveries.class) .add(10_2_018, "Drop index 'component_uuid' in 'snapshots' table", DropIndexComponentUuidInSnapshots.class) .add(10_2_019, "Rename 'component_uuid' in 'snapshots' table to 'root_component_uuid'", RenameComponentUuidInSnapshots.class) diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v102/CreateIndexProjectUuidInWebhookDeliveriesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v102/CreateIndexProjectUuidInWebhookDeliveriesTest.java deleted file mode 100644 index 51f36d315c4..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v102/CreateIndexProjectUuidInWebhookDeliveriesTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2023 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.v102; - -import java.sql.SQLException; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; - -public class CreateIndexProjectUuidInWebhookDeliveriesTest { - @Rule - public final CoreDbTester db = CoreDbTester.createForSchema(CreateIndexProjectUuidInWebhookDeliveriesTest.class, "schema.sql"); - - private final CreateIndexProjectUuidInWebhookDeliveries createIndex = new CreateIndexProjectUuidInWebhookDeliveries(db.database()); - - @Test - public void migration_should_create_index() throws SQLException { - db.assertIndexDoesNotExist("webhook_deliveries", "wd_project_uuid"); - - createIndex.execute(); - - db.assertIndex("webhook_deliveries", "wd_project_uuid", "project_uuid"); - } - - @Test - public void migration_should_be_reentrant() throws SQLException { - createIndex.execute(); - createIndex.execute(); - - db.assertIndex("webhook_deliveries", "wd_project_uuid", "project_uuid"); - } -} diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v102/CreateIndexProjectUuidInWebhookDeliveriesTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v102/CreateIndexProjectUuidInWebhookDeliveriesTest/schema.sql deleted file mode 100644 index add1899f5cf..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v102/CreateIndexProjectUuidInWebhookDeliveriesTest/schema.sql +++ /dev/null @@ -1,18 +0,0 @@ -CREATE TABLE "WEBHOOK_DELIVERIES"( - "UUID" CHARACTER VARYING(40) NOT NULL, - "WEBHOOK_UUID" CHARACTER VARYING(40) NOT NULL, - "PROJECT_UUID" CHARACTER VARYING(40) NOT NULL, - "CE_TASK_UUID" CHARACTER VARYING(40), - "ANALYSIS_UUID" CHARACTER VARYING(40), - "NAME" CHARACTER VARYING(100) NOT NULL, - "URL" CHARACTER VARYING(2000) NOT NULL, - "SUCCESS" BOOLEAN NOT NULL, - "HTTP_STATUS" INTEGER, - "DURATION_MS" BIGINT NOT NULL, - "PAYLOAD" CHARACTER LARGE OBJECT NOT NULL, - "ERROR_STACKTRACE" CHARACTER LARGE OBJECT, - "CREATED_AT" BIGINT NOT NULL -); -ALTER TABLE "WEBHOOK_DELIVERIES" ADD CONSTRAINT "PK_WEBHOOK_DELIVERIES" PRIMARY KEY("UUID"); -CREATE INDEX "CE_TASK_UUID" ON "WEBHOOK_DELIVERIES"("CE_TASK_UUID" NULLS FIRST); -CREATE INDEX "IDX_WBHK_DLVRS_WBHK_UUID" ON "WEBHOOK_DELIVERIES"("WEBHOOK_UUID" NULLS FIRST); \ No newline at end of file