diff options
author | Eric Hartmann <hartmann.eric@gmail.com> | 2017-09-27 16:44:33 +0200 |
---|---|---|
committer | Sébastien Lesaint <sebastien.lesaint@sonarsource.com> | 2017-10-17 15:13:58 +0200 |
commit | 332cb13bb6a20434d358db772386a4e87200a9a4 (patch) | |
tree | c06b7a2a022667d50ca45e4c9209d86a04f478ac /server/sonar-db-migration | |
parent | 1613b1f008e306b4dd218b37e19685ec610c5db4 (diff) | |
download | sonarqube-332cb13bb6a20434d358db772386a4e87200a9a4.tar.gz sonarqube-332cb13bb6a20434d358db772386a4e87200a9a4.zip |
SONAR-9880 Add ANALYSIS_UUID on WEBHOOK_DELIVERIES
Diffstat (limited to 'server/sonar-db-migration')
12 files changed, 470 insertions, 2 deletions
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/PopulateAnalysisUuidColumnOnWebhookDeliveries.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/PopulateAnalysisUuidColumnOnWebhookDeliveries.java new file mode 100644 index 00000000000..05b4bd7f1bf --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/PopulateAnalysisUuidColumnOnWebhookDeliveries.java @@ -0,0 +1,56 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 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.v66; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.step.DataChange; +import org.sonar.server.platform.db.migration.step.MassUpdate; +import org.sonar.server.platform.db.migration.step.Select; +import org.sonar.server.platform.db.migration.step.SqlStatement; + +public class PopulateAnalysisUuidColumnOnWebhookDeliveries extends DataChange { + + public PopulateAnalysisUuidColumnOnWebhookDeliveries(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + MassUpdate massUpdate = context.prepareMassUpdate(); + massUpdate.select("SELECT wd.uuid, ca.analysis_uuid " + + " FROM webhook_deliveries wd " + + " INNER JOIN ce_activity ca ON ca.uuid=wd.ce_task_uuid " + + " WHERE wd.analysis_uuid IS NULL AND ca.analysis_uuid IS NOT NULL"); + massUpdate.update("UPDATE webhook_deliveries SET analysis_uuid=? WHERE uuid=?"); + massUpdate.rowPluralName("webhook_deliveries"); + massUpdate.execute(PopulateAnalysisUuidColumnOnWebhookDeliveries::handle); + } + + private static boolean handle(Select.Row row, SqlStatement update) throws SQLException { + String uuid = row.getString(1); + String analysisUuid = row.getString(2); + + update.setString(1, analysisUuid); + update.setString(2, uuid); + + return true; + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/UpdateCeTaskUuidColumnToNullableOnWebhookDeliveries.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/UpdateCeTaskUuidColumnToNullableOnWebhookDeliveries.java new file mode 100644 index 00000000000..236b3cb61be --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/UpdateCeTaskUuidColumnToNullableOnWebhookDeliveries.java @@ -0,0 +1,47 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 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.v66; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.def.VarcharColumnDef; +import org.sonar.server.platform.db.migration.sql.AlterColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +public class UpdateCeTaskUuidColumnToNullableOnWebhookDeliveries extends DdlChange { + + public static final String TABLE_WEBHOOK_DELIVERIES = "webhook_deliveries"; + + public UpdateCeTaskUuidColumnToNullableOnWebhookDeliveries(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AlterColumnsBuilder(getDialect(), TABLE_WEBHOOK_DELIVERIES) + .updateColumn(VarcharColumnDef.newVarcharColumnDefBuilder() + .setColumnName("ce_task_uuid") + .setLimit(40) + .setIsNullable(true) + .build()) + .build()); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v67/AddAnalysisUuidToWebhookDeliveries.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v67/AddAnalysisUuidToWebhookDeliveries.java new file mode 100644 index 00000000000..058adf56345 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v67/AddAnalysisUuidToWebhookDeliveries.java @@ -0,0 +1,49 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 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.v67; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.def.VarcharColumnDef; +import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +public class AddAnalysisUuidToWebhookDeliveries extends DdlChange { + + public static final String TABLE = "webhook_deliveries"; + + public static final VarcharColumnDef ANALYSIS_UUID_COLUMN = VarcharColumnDef.newVarcharColumnDefBuilder() + .setColumnName("analysis_uuid") + .setLimit(40) + .setIsNullable(true) + .build(); + + public AddAnalysisUuidToWebhookDeliveries(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AddColumnsBuilder(getDialect(), TABLE) + .addColumn(ANALYSIS_UUID_COLUMN) + .build()); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v67/DbVersion67.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v67/DbVersion67.java index b02a6065997..e5b479e4d1d 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v67/DbVersion67.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v67/DbVersion67.java @@ -27,6 +27,6 @@ public class DbVersion67 implements DbVersion { public void addSteps(MigrationStepRegistry registry) { registry .add(1830, "Copy deprecated server ID", CopyDeprecatedServerId.class) - ; + .add(1831, "Add webhook_deliveries.analysis_uuid", AddAnalysisUuidToWebhookDeliveries.class); } } diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v66/PopulateAnalysisUuidColumnOnWebhookDeliveriesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v66/PopulateAnalysisUuidColumnOnWebhookDeliveriesTest.java new file mode 100644 index 00000000000..a8d73b2ce8f --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v66/PopulateAnalysisUuidColumnOnWebhookDeliveriesTest.java @@ -0,0 +1,109 @@ +package org.sonar.server.platform.db.migration.version.v66;/* + * SonarQube + * Copyright (C) 2009-2017 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. + */ + +import java.sql.SQLException; +import java.util.List; +import java.util.Map; +import javax.annotation.Nullable; +import org.apache.commons.lang.math.RandomUtils; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.sonar.db.CoreDbTester; + +import static org.apache.commons.lang.RandomStringUtils.randomAlphanumeric; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.entry; + +public class PopulateAnalysisUuidColumnOnWebhookDeliveriesTest { + private static final String TABLE_WEBHOOK_DELIVERY = "webhook_deliveries"; + private static final String TABLE_CE_ACTIVITIY = "ce_activity"; + + @Rule + public final CoreDbTester db = CoreDbTester.createForSchema(PopulateAnalysisUuidColumnOnWebhookDeliveriesTest.class, "initial.sql"); + @Rule + public ExpectedException expectedException = ExpectedException.none(); + + private PopulateAnalysisUuidColumnOnWebhookDeliveries underTest = new PopulateAnalysisUuidColumnOnWebhookDeliveries(db.database()); + + @Test + public void migration_must_set_analysis_uuid() throws SQLException { + String ceTaskUuid = randomAlphanumeric(40); + String analysisUuid = randomAlphanumeric(40); + String webhookDeliveryUuid = randomAlphanumeric(40); + insertWebhookDelivery(webhookDeliveryUuid,null, ceTaskUuid); + insertCeActivity(ceTaskUuid, analysisUuid); + + assertThat(db.countRowsOfTable(TABLE_WEBHOOK_DELIVERY)).isEqualTo(1); + assertThat(db.countRowsOfTable(TABLE_CE_ACTIVITIY)).isEqualTo(1); + underTest.execute(); + + List<Map<String, Object>> maps = selectAllWebhookDeliveries(); + assertThat(maps).hasSize(1); + assertThat(maps.get(0)).containsExactly( + entry("ANALYSIS_UUID", analysisUuid), entry("UUID", webhookDeliveryUuid), entry("CE_TASK_UUID", ceTaskUuid)); + } + + @Test + public void migration_should_be_reentrant() throws SQLException { + for (int i = 0; i < 10; i++) { + insertWebhookDelivery(randomAlphanumeric(40),null, randomAlphanumeric(40)); + insertCeActivity(randomAlphanumeric(40), randomAlphanumeric(40)); + } + + underTest.execute(); + List<Map<String, Object>> firstExecutionResult = selectAllWebhookDeliveries(); + underTest.execute(); + assertThat(selectAllWebhookDeliveries()).isEqualTo(firstExecutionResult); + } + + private List<Map<String, Object>> selectAllWebhookDeliveries() { + return db.select("select uuid, ce_task_uuid, analysis_uuid from webhook_deliveries"); + } + + private void insertCeActivity(String uuid, String analysisUuid) { + db.executeInsert(TABLE_CE_ACTIVITIY, + "UUID", uuid, + "TASK_TYPE", randomAlphanumeric(5), + "ANALYSIS_UUID", analysisUuid, + "STATUS", randomAlphanumeric(5), + "IS_LAST", RandomUtils.nextBoolean(), + "IS_LAST_KEY", randomAlphanumeric(50), + "EXECUTION_COUNT", RandomUtils.nextInt(10), + "SUBMITTED_AT", RandomUtils.nextInt(), + "CREATED_AT", RandomUtils.nextInt(), + "UPDATED_AT", RandomUtils.nextInt() + ); + } + + private void insertWebhookDelivery(String uuid, @Nullable String analysisUuid, String ceTaskUuid) { + db.executeInsert(TABLE_WEBHOOK_DELIVERY, + "UUID", uuid, + "COMPONENT_UUID", randomAlphanumeric(30), + "ANALYSIS_UUID", analysisUuid, + "CE_TASK_UUID", ceTaskUuid, + "NAME", randomAlphanumeric(15), + "URL", randomAlphanumeric(15), + "SUCCESS", RandomUtils.nextBoolean(), + "PAYLOAD", randomAlphanumeric(200), + "CREATED_AT", RandomUtils.nextInt() + ); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v66/UpdateCeTaskUuidColumnToNullableOnWebhookDeliveriesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v66/UpdateCeTaskUuidColumnToNullableOnWebhookDeliveriesTest.java new file mode 100644 index 00000000000..f2d234c44b9 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v66/UpdateCeTaskUuidColumnToNullableOnWebhookDeliveriesTest.java @@ -0,0 +1,56 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 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.v66; + +import java.sql.SQLException; +import java.sql.Types; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.sonar.db.CoreDbTester; + +import static org.assertj.core.api.Assertions.assertThat; + +public class UpdateCeTaskUuidColumnToNullableOnWebhookDeliveriesTest { + private static final String TABLE = "webhook_deliveries"; + + @Rule + public final CoreDbTester db = CoreDbTester.createForSchema(UpdateCeTaskUuidColumnToNullableOnWebhookDeliveriesTest.class, "initial.sql"); + @Rule + public ExpectedException expectedException = ExpectedException.none(); + + private UpdateCeTaskUuidColumnToNullableOnWebhookDeliveries underTest = new UpdateCeTaskUuidColumnToNullableOnWebhookDeliveries(db.database()); + + @Test + public void update_column() throws SQLException { + underTest.execute(); + + assertThat(db.countRowsOfTable(TABLE)).isEqualTo(0); + db.assertColumnDefinition(TABLE, "ce_task_uuid", Types.VARCHAR, 40, true); + db.assertColumnDefinition(TABLE, "analysis_uuid", Types.VARCHAR, 40, true); + } + + @Test + public void migration_is_reentrant() throws SQLException { + underTest.execute(); + underTest.execute(); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v67/AddAnalysisUuidToWebhookDeliveriesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v67/AddAnalysisUuidToWebhookDeliveriesTest.java new file mode 100644 index 00000000000..63a59e46b0d --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v67/AddAnalysisUuidToWebhookDeliveriesTest.java @@ -0,0 +1,55 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 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.v67; + +import java.sql.SQLException; +import java.sql.Types; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.sonar.db.CoreDbTester; + +public class AddAnalysisUuidToWebhookDeliveriesTest { + + private static final String TABLE = "webhook_deliveries"; + + @Rule + public final CoreDbTester db = CoreDbTester.createForSchema(AddAnalysisUuidToWebhookDeliveriesTest.class, "initial.sql"); + @Rule + public ExpectedException expectedException = ExpectedException.none(); + + private AddAnalysisUuidToWebhookDeliveries underTest = new AddAnalysisUuidToWebhookDeliveries(db.database()); + + @Test + public void add_column() throws SQLException { + underTest.execute(); + + db.assertColumnDefinition(TABLE, "analysis_uuid", Types.VARCHAR, 40, true); + } + + @Test + public void migration_is_not_reentrant() throws SQLException { + underTest.execute(); + + expectedException.expect(IllegalStateException.class); + + underTest.execute(); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v67/DbVersion67Test.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v67/DbVersion67Test.java index 41ea47048be..ada1069cc8d 100644 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v67/DbVersion67Test.java +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v67/DbVersion67Test.java @@ -36,7 +36,7 @@ public class DbVersion67Test { @Test public void verify_migration_count() { - verifyMigrationCount(underTest, 1); + verifyMigrationCount(underTest, 2); } } diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v66/MakeAnalysisUuidNotNullOnWebhookDeliveriesTest/initial.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v66/MakeAnalysisUuidNotNullOnWebhookDeliveriesTest/initial.sql new file mode 100644 index 00000000000..1d8b219839a --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v66/MakeAnalysisUuidNotNullOnWebhookDeliveriesTest/initial.sql @@ -0,0 +1,17 @@ +CREATE TABLE "WEBHOOK_DELIVERIES" ( + "UUID" VARCHAR(40) NOT NULL PRIMARY KEY, + "COMPONENT_UUID" VARCHAR(40) NOT NULL, + "ANALYSIS_UUID" VARCHAR(40), + "CE_TASK_UUID" VARCHAR(40), + "NAME" VARCHAR(100) NOT NULL, + "URL" VARCHAR(2000) NOT NULL, + "SUCCESS" BOOLEAN NOT NULL, + "HTTP_STATUS" INT, + "DURATION_MS" INT, + "PAYLOAD" CLOB NOT NULL, + "ERROR_STACKTRACE" CLOB, + "CREATED_AT" BIGINT NOT NULL +); +CREATE UNIQUE INDEX "PK_WEBHOOK_DELIVERIES" ON "WEBHOOK_DELIVERIES" ("UUID"); +CREATE INDEX "COMPONENT_UUID" ON "WEBHOOK_DELIVERIES" ("COMPONENT_UUID"); +CREATE INDEX "CE_TASK_UUID" ON "WEBHOOK_DELIVERIES" ("CE_TASK_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v66/PopulateAnalysisUuidColumnOnWebhookDeliveriesTest/initial.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v66/PopulateAnalysisUuidColumnOnWebhookDeliveriesTest/initial.sql new file mode 100644 index 00000000000..de520902cff --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v66/PopulateAnalysisUuidColumnOnWebhookDeliveriesTest/initial.sql @@ -0,0 +1,46 @@ +CREATE TABLE "CE_ACTIVITY" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "UUID" VARCHAR(40) NOT NULL, + "TASK_TYPE" VARCHAR(15) NOT NULL, + "COMPONENT_UUID" VARCHAR(40) NULL, + "ANALYSIS_UUID" VARCHAR(50) NULL, + "STATUS" VARCHAR(15) NOT NULL, + "IS_LAST" BOOLEAN NOT NULL, + "IS_LAST_KEY" VARCHAR(55) NOT NULL, + "SUBMITTER_LOGIN" VARCHAR(255) NULL, + "WORKER_UUID" VARCHAR(40) NULL, + "EXECUTION_COUNT" INTEGER NOT NULL, + "SUBMITTED_AT" BIGINT NOT NULL, + "STARTED_AT" BIGINT NULL, + "EXECUTED_AT" BIGINT NULL, + "CREATED_AT" BIGINT NOT NULL, + "UPDATED_AT" BIGINT NOT NULL, + "EXECUTION_TIME_MS" BIGINT NULL, + "ERROR_MESSAGE" VARCHAR(1000), + "ERROR_STACKTRACE" CLOB(2147483647) +); + +CREATE UNIQUE INDEX "CE_ACTIVITY_UUID" ON "CE_ACTIVITY" ("UUID"); +CREATE INDEX "CE_ACTIVITY_COMPONENT_UUID" ON "CE_ACTIVITY" ("COMPONENT_UUID"); +CREATE INDEX "CE_ACTIVITY_ISLASTKEY" ON "CE_ACTIVITY" ("IS_LAST_KEY"); +CREATE INDEX "CE_ACTIVITY_ISLAST_STATUS" ON "CE_ACTIVITY" ("IS_LAST", "STATUS"); + + +CREATE TABLE "WEBHOOK_DELIVERIES" ( + "UUID" VARCHAR(40) NOT NULL PRIMARY KEY, + "COMPONENT_UUID" VARCHAR(40) NOT NULL, + "ANALYSIS_UUID" VARCHAR(40), + "CE_TASK_UUID" VARCHAR(40), + "NAME" VARCHAR(100) NOT NULL, + "URL" VARCHAR(2000) NOT NULL, + "SUCCESS" BOOLEAN NOT NULL, + "HTTP_STATUS" INT, + "DURATION_MS" INT, + "PAYLOAD" CLOB NOT NULL, + "ERROR_STACKTRACE" CLOB, + "CREATED_AT" BIGINT NOT NULL +); +CREATE UNIQUE INDEX "PK_WEBHOOK_DELIVERIES" ON "WEBHOOK_DELIVERIES" ("UUID"); +CREATE INDEX "COMPONENT_UUID" ON "WEBHOOK_DELIVERIES" ("COMPONENT_UUID"); +CREATE INDEX "CE_TASK_UUID" ON "WEBHOOK_DELIVERIES" ("CE_TASK_UUID"); +CREATE INDEX "ANALYSES_UUID" ON "WEBHOOK_DELIVERIES" ("ANALYSIS_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v66/UpdateCeTaskUuidColumnToNullableOnWebhookDeliveriesTest/initial.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v66/UpdateCeTaskUuidColumnToNullableOnWebhookDeliveriesTest/initial.sql new file mode 100644 index 00000000000..0e120b5f08a --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v66/UpdateCeTaskUuidColumnToNullableOnWebhookDeliveriesTest/initial.sql @@ -0,0 +1,17 @@ +CREATE TABLE "WEBHOOK_DELIVERIES" ( + "UUID" VARCHAR(40) NOT NULL PRIMARY KEY, + "COMPONENT_UUID" VARCHAR(40) NOT NULL, + "ANALYSIS_UUID" VARCHAR(40) NULL, + "CE_TASK_UUID" VARCHAR(40) NOT NULL, + "NAME" VARCHAR(100) NOT NULL, + "URL" VARCHAR(2000) NOT NULL, + "SUCCESS" BOOLEAN NOT NULL, + "HTTP_STATUS" INT, + "DURATION_MS" INT, + "PAYLOAD" CLOB NOT NULL, + "ERROR_STACKTRACE" CLOB, + "CREATED_AT" BIGINT NOT NULL +); +CREATE UNIQUE INDEX "PK_WEBHOOK_DELIVERIES" ON "WEBHOOK_DELIVERIES" ("UUID"); +CREATE INDEX "COMPONENT_UUID" ON "WEBHOOK_DELIVERIES" ("COMPONENT_UUID"); +CREATE INDEX "CE_TASK_UUID" ON "WEBHOOK_DELIVERIES" ("CE_TASK_UUID"); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v67/AddAnalysisUuidToWebhookDeliveriesTest/initial.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v67/AddAnalysisUuidToWebhookDeliveriesTest/initial.sql new file mode 100644 index 00000000000..e4509afd200 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v67/AddAnalysisUuidToWebhookDeliveriesTest/initial.sql @@ -0,0 +1,16 @@ +CREATE TABLE "WEBHOOK_DELIVERIES" ( + "UUID" VARCHAR(40) NOT NULL PRIMARY KEY, + "COMPONENT_UUID" VARCHAR(40) NOT NULL, + "CE_TASK_UUID" VARCHAR(40) NOT NULL, + "NAME" VARCHAR(100) NOT NULL, + "URL" VARCHAR(2000) NOT NULL, + "SUCCESS" BOOLEAN NOT NULL, + "HTTP_STATUS" INT, + "DURATION_MS" INT, + "PAYLOAD" CLOB NOT NULL, + "ERROR_STACKTRACE" CLOB, + "CREATED_AT" BIGINT NOT NULL +); +CREATE UNIQUE INDEX "PK_WEBHOOK_DELIVERIES" ON "WEBHOOK_DELIVERIES" ("UUID"); +CREATE INDEX "COMPONENT_UUID" ON "WEBHOOK_DELIVERIES" ("COMPONENT_UUID"); +CREATE INDEX "CE_TASK_UUID" ON "WEBHOOK_DELIVERIES" ("CE_TASK_UUID"); |