From b26ae4c3687b9bf4a2ae809702c5663959627a2f Mon Sep 17 00:00:00 2001 From: Pierre Date: Fri, 9 Apr 2021 11:43:52 +0200 Subject: [PATCH] SONAR-14681 improve live_measures metric purge performance --- .../db/migration/version/v82/DbVersion82.java | 6 +- ...eleteSecurityReviewRatingLiveMeasures.java | 67 ++++++++++ ...eSecurityReviewRatingProjectMeasures.java} | 28 +---- ...SecurityReviewRatingLiveMeasuresTest.java} | 118 +++--------------- .../schema.sql | 22 ---- 5 files changed, 88 insertions(+), 153 deletions(-) create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v82/DeleteSecurityReviewRatingLiveMeasures.java rename server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v82/{DeleteSecurityReviewRatingMeasures.java => DeleteSecurityReviewRatingProjectMeasures.java} (71%) rename server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v82/{DeleteSecurityReviewRatingMeasuresTest.java => DeleteSecurityReviewRatingLiveMeasuresTest.java} (54%) rename server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v82/{DeleteSecurityReviewRatingMeasuresTest => DeleteSecurityReviewRatingLiveMeasuresTest}/schema.sql (78%) diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v82/DbVersion82.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v82/DbVersion82.java index f4cc3dffb4c..475899465d7 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v82/DbVersion82.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v82/DbVersion82.java @@ -34,9 +34,11 @@ public class DbVersion82 implements DbVersion { .add(3205, "Add PROJECTS table", CreateProjectsTable.class) .add(3206, "Populate PROJECTS table", PopulateProjectsTable.class) .add(3207, "Drop 'TAGS' column from COMPONENTS table", DropTagsColumnFromComponentsTable.class) - .add(3208, "Remove old Security Review Rating measures", DeleteSecurityReviewRatingMeasures.class) .add(3209, "Create ALM_PATS table", CreateAlmPatsTable.class) .add(3210, "Add index on ALM_slug", AddIndexOnSlugOfProjectAlmSettings.class) - .add(3211, "Delete conditions using 'security_hotspots' and 'new_security_hotspots' metrics", DeleteQgateConditionsUsingSecurityHotspotMetrics.class); + .add(3211, "Delete conditions using 'security_hotspots' and 'new_security_hotspots' metrics", DeleteQgateConditionsUsingSecurityHotspotMetrics.class) + .add(3212, "Remove old Security Review Rating LiveMeasures", DeleteSecurityReviewRatingLiveMeasures.class) + + ; } } diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v82/DeleteSecurityReviewRatingLiveMeasures.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v82/DeleteSecurityReviewRatingLiveMeasures.java new file mode 100644 index 00000000000..4808e77bb89 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v82/DeleteSecurityReviewRatingLiveMeasures.java @@ -0,0 +1,67 @@ +/* + * SonarQube + * Copyright (C) 2009-2021 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.v82; + +import java.sql.SQLException; +import javax.annotation.Nullable; +import org.sonar.db.Database; +import org.sonar.server.platform.db.migration.step.DataChange; +import org.sonar.server.platform.db.migration.step.MassUpdate; + +public class DeleteSecurityReviewRatingLiveMeasures extends DataChange { + + private static final String SECURITY_REVIEW_RATING_METRIC_KEY = "security_review_rating"; + private static final String SECURITY_REVIEW_RATING_EFFORT_METRIC_KEY = "security_review_rating_effort"; + + public DeleteSecurityReviewRatingLiveMeasures(Database db) { + super(db); + } + + @Override + protected void execute(Context context) throws SQLException { + Integer reviewRatingId = getMetricId(context, SECURITY_REVIEW_RATING_METRIC_KEY); + Integer reviewRatingEffortId = getMetricId(context, SECURITY_REVIEW_RATING_EFFORT_METRIC_KEY); + deleteMetricFromLiveMeasures(context, reviewRatingId); + deleteMetricFromLiveMeasures(context, reviewRatingEffortId); + } + + @Nullable + private static Integer getMetricId(Context context, String metricName) throws SQLException { + return context.prepareSelect("select id from metrics where name = ?") + .setString(1, metricName) + .get(row -> row.getNullableInt(1)); + } + + private static void deleteMetricFromLiveMeasures(Context context, @Nullable Integer metricId) throws SQLException { + if (metricId == null) { + return; + } + MassUpdate massUpdate = context.prepareMassUpdate(); + + massUpdate.select("select lm.uuid from live_measures lm inner join components c on lm.component_uuid = c.uuid and lm.metric_id = ?") + .setInt(1, metricId); + massUpdate.update("delete from live_measures where uuid = ?"); + + massUpdate.execute((row, update) -> { + update.setString(1, row.getString(1)); + return true; + }); + } +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v82/DeleteSecurityReviewRatingMeasures.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v82/DeleteSecurityReviewRatingProjectMeasures.java similarity index 71% rename from server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v82/DeleteSecurityReviewRatingMeasures.java rename to server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v82/DeleteSecurityReviewRatingProjectMeasures.java index 1ded44dd670..cdadbe18934 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v82/DeleteSecurityReviewRatingMeasures.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v82/DeleteSecurityReviewRatingProjectMeasures.java @@ -25,13 +25,13 @@ import org.sonar.db.Database; import org.sonar.server.platform.db.migration.step.DataChange; import org.sonar.server.platform.db.migration.step.MassUpdate; -public class DeleteSecurityReviewRatingMeasures extends DataChange { +public class DeleteSecurityReviewRatingProjectMeasures extends DataChange { private static final String SECURITY_REVIEW_RATING_METRIC_KEY = "security_review_rating"; private static final String SECURITY_REVIEW_RATING_EFFORT_METRIC_KEY = "security_review_rating_effort"; - private static final String SELECT_COMPONENTS_STATEMENT = "select c.uuid from components c where c.scope in ('PRJ') and c.qualifier in ('VW', 'SVW', 'APP', 'TRK')"; + private static final String SELECT_COMPONENTS_STATEMENT = "select c.uuid from components c where c.scope in ('PRJ')"; - public DeleteSecurityReviewRatingMeasures(Database db) { + public DeleteSecurityReviewRatingProjectMeasures(Database db) { super(db); } @@ -41,7 +41,6 @@ public class DeleteSecurityReviewRatingMeasures extends DataChange { Integer reviewRatingEffortId = getMetricId(context, SECURITY_REVIEW_RATING_EFFORT_METRIC_KEY); if (reviewRatingId != null) { deleteFromProjectMeasures(context, reviewRatingId, reviewRatingEffortId); - deleteFromLiveMeasures(context, reviewRatingId, reviewRatingEffortId); } } @@ -52,27 +51,6 @@ public class DeleteSecurityReviewRatingMeasures extends DataChange { .get(row -> row.getNullableInt(1)); } - private static void deleteFromLiveMeasures(Context context, Integer reviewRatingId, @Nullable Integer reviewRatingEffortId) throws SQLException { - MassUpdate deleteFromLiveMeasures = context.prepareMassUpdate(); - - deleteFromLiveMeasures.select(SELECT_COMPONENTS_STATEMENT); - if (reviewRatingEffortId != null) { - deleteFromLiveMeasures.update("delete from live_measures where project_uuid = ? and metric_id in (?, ?)"); - } else { - deleteFromLiveMeasures.update("delete from live_measures where project_uuid = ? and metric_id = ?"); - } - - deleteFromLiveMeasures.execute((row, update) -> { - String projectUuid = row.getString(1); - update.setString(1, projectUuid) - .setInt(2, reviewRatingId); - if (reviewRatingEffortId != null) { - update.setInt(3, reviewRatingEffortId); - } - return true; - }); - } - private static void deleteFromProjectMeasures(Context context, Integer reviewRatingId, @Nullable Integer reviewRatingEffortId) throws SQLException { MassUpdate deleteFromProjectMeasures = context.prepareMassUpdate(); diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v82/DeleteSecurityReviewRatingMeasuresTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v82/DeleteSecurityReviewRatingLiveMeasuresTest.java similarity index 54% rename from server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v82/DeleteSecurityReviewRatingMeasuresTest.java rename to server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v82/DeleteSecurityReviewRatingLiveMeasuresTest.java index 5785339655e..3e9e602087d 100644 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v82/DeleteSecurityReviewRatingMeasuresTest.java +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v82/DeleteSecurityReviewRatingLiveMeasuresTest.java @@ -20,7 +20,6 @@ package org.sonar.server.platform.db.migration.version.v82; import java.sql.SQLException; -import java.util.Random; import java.util.UUID; import java.util.stream.Collectors; import java.util.stream.IntStream; @@ -33,8 +32,7 @@ import org.sonar.server.platform.db.migration.step.DataChange; import static org.apache.commons.lang.math.RandomUtils.nextInt; import static org.assertj.core.api.Assertions.assertThat; -public class DeleteSecurityReviewRatingMeasuresTest { - private static final String PROJECT_MEASURES_TABLE_NAME = "PROJECT_MEASURES"; +public class DeleteSecurityReviewRatingLiveMeasuresTest { private static final String LIVE_MEASURES_TABLE_NAME = "LIVE_MEASURES"; private static final int SECURITY_REVIEW_RATING_METRIC_ID = 200; @@ -47,9 +45,9 @@ public class DeleteSecurityReviewRatingMeasuresTest { private static final int OTHER_METRIC_MEASURES_COUNT = 20; @Rule - public CoreDbTester db = CoreDbTester.createForSchema(DeleteSecurityReviewRatingMeasuresTest.class, "schema.sql"); + public CoreDbTester db = CoreDbTester.createForSchema(DeleteSecurityReviewRatingLiveMeasuresTest.class, "schema.sql"); - private final DataChange underTest = new DeleteSecurityReviewRatingMeasures(db.database()); + private final DataChange underTest = new DeleteSecurityReviewRatingLiveMeasures(db.database()); @Before public void before() { @@ -59,13 +57,11 @@ public class DeleteSecurityReviewRatingMeasuresTest { @Test public void not_fail_if_metrics_not_defined() throws SQLException { - String projectUuid = insertComponent("PRJ", "TRK"); - insertMeasure(1, SECURITY_REVIEW_RATING_METRIC_ID, projectUuid); + String projectUuid = insertComponent("TRK"); insertLiveMeasure("uuid-1", SECURITY_REVIEW_RATING_METRIC_ID, projectUuid, projectUuid); underTest.execute(); - assertThat(db.countRowsOfTable(PROJECT_MEASURES_TABLE_NAME)).isEqualTo(1); assertThat(db.countRowsOfTable(LIVE_MEASURES_TABLE_NAME)).isEqualTo(1); } @@ -73,20 +69,16 @@ public class DeleteSecurityReviewRatingMeasuresTest { public void not_fail_if_security_review_rating_effort_metric_not_found() throws SQLException { insertMetric(SECURITY_REVIEW_RATING_METRIC_ID, SECURITY_REVIEW_RATING_METRIC_KEY); - String applicationUuid = insertComponent("PRJ", "TRK"); + String applicationUuid = insertComponent("TRK"); - insertMeasure(1, SECURITY_REVIEW_RATING_METRIC_ID, applicationUuid); insertLiveMeasure("uuid-1", SECURITY_REVIEW_RATING_METRIC_ID, applicationUuid, applicationUuid); - generateOtherMetricMeasures(2, applicationUuid); generateOtherMetricsLiveMeasures(applicationUuid); underTest.execute(); - assertSecurityReviewRatingMeasuresDeleted(); assertSecurityReviewRatingLiveMeasuresDeleted(); - assertThat(db.countRowsOfTable(PROJECT_MEASURES_TABLE_NAME)).isEqualTo(OTHER_METRIC_MEASURES_COUNT); assertThat(db.countRowsOfTable(LIVE_MEASURES_TABLE_NAME)).isEqualTo(OTHER_METRIC_MEASURES_COUNT); // should not fail if called twice @@ -94,24 +86,20 @@ public class DeleteSecurityReviewRatingMeasuresTest { } @Test - public void remove_security_rating_review_from_measures_and_live_measures_projects() throws SQLException { + public void remove_security_rating_review_from_live_measures_projects() throws SQLException { insertMetric(SECURITY_REVIEW_RATING_METRIC_ID, SECURITY_REVIEW_RATING_METRIC_KEY); insertMetric(SECURITY_REVIEW_RATING_EFFORT_METRIC_ID, SECURITY_REVIEW_RATING_EFFORT_METRIC_KEY); - String applicationUuid = insertComponent("PRJ", "TRK"); + String applicationUuid = insertComponent("TRK"); - insertMeasure(1, SECURITY_REVIEW_RATING_METRIC_ID, applicationUuid); insertLiveMeasure("uuid-1", SECURITY_REVIEW_RATING_METRIC_ID, applicationUuid, applicationUuid); - generateOtherMetricMeasures(2, applicationUuid); generateOtherMetricsLiveMeasures(applicationUuid); underTest.execute(); - assertSecurityReviewRatingMeasuresDeleted(); assertSecurityReviewRatingLiveMeasuresDeleted(); - assertThat(db.countRowsOfTable(PROJECT_MEASURES_TABLE_NAME)).isEqualTo(OTHER_METRIC_MEASURES_COUNT); assertThat(db.countRowsOfTable(LIVE_MEASURES_TABLE_NAME)).isEqualTo(OTHER_METRIC_MEASURES_COUNT); // should not fail if called twice @@ -119,18 +107,12 @@ public class DeleteSecurityReviewRatingMeasuresTest { } @Test - public void remove_security_rating_review_from_measures_and_live_measures_for_portfolios() throws SQLException { + public void remove_security_rating_review_from_live_measures_for_portfolios() throws SQLException { insertMetric(SECURITY_REVIEW_RATING_METRIC_ID, SECURITY_REVIEW_RATING_METRIC_KEY); insertMetric(SECURITY_REVIEW_RATING_EFFORT_METRIC_ID, SECURITY_REVIEW_RATING_EFFORT_METRIC_KEY); - String portfolioUuid = insertComponent("PRJ", "VW"); - String subPortfolioUuid = insertComponent("PRJ", "SVW"); - - insertMeasure(1, SECURITY_REVIEW_RATING_METRIC_ID, portfolioUuid); - insertMeasure(2, SECURITY_REVIEW_RATING_METRIC_ID, subPortfolioUuid); - - insertMeasure(3, SECURITY_REVIEW_RATING_EFFORT_METRIC_ID, portfolioUuid); - insertMeasure(4, SECURITY_REVIEW_RATING_EFFORT_METRIC_ID, subPortfolioUuid); + String portfolioUuid = insertComponent("VW"); + String subPortfolioUuid = insertComponent("SVW"); insertLiveMeasure("uuid-1", SECURITY_REVIEW_RATING_METRIC_ID, portfolioUuid, portfolioUuid); insertLiveMeasure("uuid-2", SECURITY_REVIEW_RATING_METRIC_ID, subPortfolioUuid, subPortfolioUuid); @@ -138,16 +120,12 @@ public class DeleteSecurityReviewRatingMeasuresTest { insertLiveMeasure("uuid-3", SECURITY_REVIEW_RATING_EFFORT_METRIC_ID, portfolioUuid, portfolioUuid); insertLiveMeasure("uuid-4", SECURITY_REVIEW_RATING_EFFORT_METRIC_ID, subPortfolioUuid, subPortfolioUuid); - - generateOtherMetricMeasures(5, portfolioUuid); generateOtherMetricsLiveMeasures(portfolioUuid); underTest.execute(); - assertSecurityReviewRatingMeasuresDeleted(); assertSecurityReviewRatingLiveMeasuresDeleted(); - assertThat(db.countRowsOfTable(PROJECT_MEASURES_TABLE_NAME)).isEqualTo(OTHER_METRIC_MEASURES_COUNT); assertThat(db.countRowsOfTable(LIVE_MEASURES_TABLE_NAME)).isEqualTo(OTHER_METRIC_MEASURES_COUNT); // should not fail if called twice @@ -155,67 +133,20 @@ public class DeleteSecurityReviewRatingMeasuresTest { } @Test - public void remove_security_rating_review_from_measures_and_live_measures_applications() throws SQLException { + public void remove_security_rating_review_from_live_measures_applications() throws SQLException { insertMetric(SECURITY_REVIEW_RATING_METRIC_ID, SECURITY_REVIEW_RATING_METRIC_KEY); insertMetric(SECURITY_REVIEW_RATING_EFFORT_METRIC_ID, SECURITY_REVIEW_RATING_EFFORT_METRIC_KEY); - String applicationUuid = insertComponent("PRJ", "APP"); + String applicationUuid = insertComponent("APP"); - insertMeasure(1, SECURITY_REVIEW_RATING_METRIC_ID, applicationUuid); insertLiveMeasure("uuid-1", SECURITY_REVIEW_RATING_METRIC_ID, applicationUuid, applicationUuid); - generateOtherMetricMeasures(2, applicationUuid); generateOtherMetricsLiveMeasures(applicationUuid); underTest.execute(); - assertSecurityReviewRatingMeasuresDeleted(); - assertSecurityReviewRatingLiveMeasuresDeleted(); - - assertThat(db.countRowsOfTable(PROJECT_MEASURES_TABLE_NAME)).isEqualTo(OTHER_METRIC_MEASURES_COUNT); - assertThat(db.countRowsOfTable(LIVE_MEASURES_TABLE_NAME)).isEqualTo(OTHER_METRIC_MEASURES_COUNT); - - // should not fail if called twice - underTest.execute(); - } - - @Test - public void remove_security_rating_review_from_measures_and_live_measures_mixed() throws SQLException { - insertMetric(SECURITY_REVIEW_RATING_METRIC_ID, SECURITY_REVIEW_RATING_METRIC_KEY); - insertMetric(SECURITY_REVIEW_RATING_EFFORT_METRIC_ID, SECURITY_REVIEW_RATING_EFFORT_METRIC_KEY); - - String portfolioUuid = insertComponent("PRJ", "VW"); - String subPortfolioUuid = insertComponent("PRJ", "SVW"); - String applicationUuid = insertComponent("PRJ", "APP"); - String projectUuid = insertComponent("PRJ", "TRK"); - - insertMeasure(1, SECURITY_REVIEW_RATING_METRIC_ID, portfolioUuid); - insertMeasure(2, SECURITY_REVIEW_RATING_METRIC_ID, subPortfolioUuid); - insertMeasure(3, SECURITY_REVIEW_RATING_METRIC_ID, applicationUuid); - insertMeasure(4, SECURITY_REVIEW_RATING_METRIC_ID, projectUuid); - - insertMeasure(5, SECURITY_REVIEW_RATING_EFFORT_METRIC_ID, portfolioUuid); - insertMeasure(6, SECURITY_REVIEW_RATING_EFFORT_METRIC_ID, subPortfolioUuid); - - insertLiveMeasure("uuid-1", SECURITY_REVIEW_RATING_METRIC_ID, portfolioUuid, portfolioUuid); - insertLiveMeasure("uuid-2", SECURITY_REVIEW_RATING_METRIC_ID, subPortfolioUuid, subPortfolioUuid); - insertLiveMeasure("uuid-3", SECURITY_REVIEW_RATING_METRIC_ID, applicationUuid, applicationUuid); - insertLiveMeasure("uuid-4", SECURITY_REVIEW_RATING_METRIC_ID, projectUuid, projectUuid); - insertLiveMeasure("uuid-5", SECURITY_REVIEW_RATING_METRIC_ID, projectUuid, getRandomUuid()); - insertLiveMeasure("uuid-6", SECURITY_REVIEW_RATING_METRIC_ID, projectUuid, getRandomUuid()); - - insertLiveMeasure("uuid-7", SECURITY_REVIEW_RATING_EFFORT_METRIC_ID, portfolioUuid, portfolioUuid); - insertLiveMeasure("uuid-8", SECURITY_REVIEW_RATING_EFFORT_METRIC_ID, subPortfolioUuid, subPortfolioUuid); - - generateOtherMetricMeasures(7, projectUuid); - generateOtherMetricsLiveMeasures(projectUuid); - - underTest.execute(); - - assertSecurityReviewRatingMeasuresDeleted(); assertSecurityReviewRatingLiveMeasuresDeleted(); - assertThat(db.countRowsOfTable(PROJECT_MEASURES_TABLE_NAME)).isEqualTo(OTHER_METRIC_MEASURES_COUNT); assertThat(db.countRowsOfTable(LIVE_MEASURES_TABLE_NAME)).isEqualTo(OTHER_METRIC_MEASURES_COUNT); // should not fail if called twice @@ -228,7 +159,6 @@ public class DeleteSecurityReviewRatingMeasuresTest { underTest.execute(); - assertThat(db.countRowsOfTable(PROJECT_MEASURES_TABLE_NAME)).isZero(); assertThat(db.countRowsOfTable(LIVE_MEASURES_TABLE_NAME)).isZero(); } @@ -239,31 +169,11 @@ public class DeleteSecurityReviewRatingMeasuresTest { .collect(Collectors.toList()); } - private void generateOtherMetricMeasures(int startId, String componentUuid) { - IntStream.range(startId, startId + OTHER_METRIC_MEASURES_COUNT) - .peek(i -> insertMeasure(i, new Random().nextBoolean() ? OTHER_METRIC_ID_1 : OTHER_METRIC_ID_2, componentUuid)) - .boxed() - .collect(Collectors.toList()); - } - private void assertSecurityReviewRatingLiveMeasuresDeleted() { assertThat(db.countSql("select count(uuid) from LIVE_MEASURES where metric_id = " + SECURITY_REVIEW_RATING_METRIC_ID)) .isZero(); } - private void assertSecurityReviewRatingMeasuresDeleted() { - assertThat(db.countSql("select count(id) from project_measures where metric_id = " + SECURITY_REVIEW_RATING_METRIC_ID)) - .isZero(); - } - - private void insertMeasure(int id, int metricId, String componentUuid) { - db.executeInsert("PROJECT_MEASURES", - "ID", id, - "METRIC_ID", metricId, - "ANALYSIS_UUID", getRandomUuid(), - "COMPONENT_UUID", componentUuid); - } - private String getRandomUuid() { return UUID.randomUUID().toString(); } @@ -286,7 +196,7 @@ public class DeleteSecurityReviewRatingMeasuresTest { "QUALITATIVE", true); } - private String insertComponent(String scope, String qualifier) { + private String insertComponent(String qualifier) { int id = nextInt(); String uuid = getRandomUuid(); db.executeInsert("COMPONENTS", @@ -297,7 +207,7 @@ public class DeleteSecurityReviewRatingMeasuresTest { "UUID_PATH", ".", "ROOT_UUID", uuid, "PRIVATE", Boolean.toString(false), - "SCOPE", scope, + "SCOPE", "PRJ", "QUALIFIER", qualifier); return uuid; } diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v82/DeleteSecurityReviewRatingMeasuresTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v82/DeleteSecurityReviewRatingLiveMeasuresTest/schema.sql similarity index 78% rename from server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v82/DeleteSecurityReviewRatingMeasuresTest/schema.sql rename to server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v82/DeleteSecurityReviewRatingLiveMeasuresTest/schema.sql index 8afa160d62e..3a0e16b77b0 100644 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v82/DeleteSecurityReviewRatingMeasuresTest/schema.sql +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v82/DeleteSecurityReviewRatingLiveMeasuresTest/schema.sql @@ -80,25 +80,3 @@ CREATE TABLE "LIVE_MEASURES"( ALTER TABLE "LIVE_MEASURES" ADD CONSTRAINT "PK_LIVE_MEASURES" PRIMARY KEY("UUID"); CREATE INDEX "LIVE_MEASURES_PROJECT" ON "LIVE_MEASURES"("PROJECT_UUID"); CREATE UNIQUE INDEX "LIVE_MEASURES_COMPONENT" ON "LIVE_MEASURES"("COMPONENT_UUID", "METRIC_ID"); - -CREATE TABLE "PROJECT_MEASURES"( - "ID" BIGINT NOT NULL AUTO_INCREMENT (1,1), - "VALUE" DOUBLE, - "METRIC_ID" INTEGER NOT NULL, - "ANALYSIS_UUID" VARCHAR(50) NOT NULL, - "COMPONENT_UUID" VARCHAR(50) NOT NULL, - "TEXT_VALUE" VARCHAR(4000), - "ALERT_STATUS" VARCHAR(5), - "ALERT_TEXT" VARCHAR(4000), - "DESCRIPTION" VARCHAR(4000), - "PERSON_ID" INTEGER, - "VARIATION_VALUE_1" DOUBLE, - "VARIATION_VALUE_2" DOUBLE, - "VARIATION_VALUE_3" DOUBLE, - "VARIATION_VALUE_4" DOUBLE, - "VARIATION_VALUE_5" DOUBLE, - "MEASURE_DATA" BLOB -); -ALTER TABLE "PROJECT_MEASURES" ADD CONSTRAINT "PK_PROJECT_MEASURES" PRIMARY KEY("ID"); -CREATE INDEX "MEASURES_ANALYSIS_METRIC" ON "PROJECT_MEASURES"("ANALYSIS_UUID", "METRIC_ID"); -CREATE INDEX "MEASURES_COMPONENT_UUID" ON "PROJECT_MEASURES"("COMPONENT_UUID"); -- 2.39.5