.add(10_2_027, "Populate column 'created_at_temp' in 'components' table", PopulateCreatedAtTempInComponents.class)
.add(10_2_028, "Drop column 'created_at' in 'components' table", DropCreatedAtInComponents.class)
.add(10_2_029, "Rename column 'created_at_temp' to 'created_at' in 'components' table", RenameCreatedAtTempInComponents.class)
+
.add(10_2_030, "Create table 'anticipated_transitions'", CreateAnticipatedTransitionsTable.class)
.add(10_2_031, "Increase size of 'ce_queue.is_last_key' from 55 to 80 characters", IncreaseIsLastKeyInCeActivity.class)
.add(10_2_034, "Populate 'clean_code_attribute' column in 'rules' table", PopulateCleanCodeAttributeColumnInRules.class)
//TODO SONAR-20073
//.add(10_2_035, "Make 'clean_code_attribute' column not nullable in 'rules' table", MakeCleanCodeAttributeColumnNotNullableInRules.class);
-
+
.add(10_2_036, "Create 'rules_default_impacts' table", CreateRulesDefaultImpactsTable.class)
.add(10_2_037, "Create unique constraint index on 'rules_default_impacts' table", CreateUniqueConstraintOnRulesDefaultImpacts.class)
.add(10_2_038, "Create 'issues_impacts' table", CreateIssueImpactsTable.class)
.add(10_2_039, "Create unique constraint index on 'issues_impacts' table", CreateUniqueConstraintOnIssuesImpacts.class)
- .add(10_2_040, "Populate default impacts for existing rules", PopulateDefaultImpactsInRules.class);
+ .add(10_2_040, "Populate default impacts for existing rules", PopulateDefaultImpactsInRules.class)
+ .add(10_2_041, "Fix sqale_index metric description in 'metrics' table", FixSqaleIndexMetricDescription.class);
}
}
--- /dev/null
+/*
+ * 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.sonar.db.Database;
+import org.sonar.server.platform.db.migration.step.DataChange;
+import org.sonar.server.platform.db.migration.step.Upsert;
+
+public class FixSqaleIndexMetricDescription extends DataChange {
+
+ public FixSqaleIndexMetricDescription(Database db) {
+ super(db);
+ }
+
+ @Override
+ protected void execute(Context context) throws SQLException {
+ try (Upsert upsert = context.prepareUpsert("update metrics set description = ? where name = ?")) {
+ upsert.setString(1, "Total effort (in minutes) to fix all the issues on the component and therefore to comply to all the requirements.");
+ upsert.setString(2, "sqale_index");
+ upsert.execute();
+ upsert.commit();
+ }
+ }
+}
--- /dev/null
+/*
+ * 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.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.sonar.db.CoreDbTester;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class FixSqaleIndexMetricDescriptionTest {
+
+ @Rule
+ public final CoreDbTester db = CoreDbTester.createForSchema(FixSqaleIndexMetricDescriptionTest.class, "schema.sql");
+
+ private final FixSqaleIndexMetricDescription underTest = new FixSqaleIndexMetricDescription(db.database());
+ private final String OLD_DESCRIPTION = "Total effort (in hours) to fix all the issues on the component and therefore to comply to all the requirements.";
+ private final String NEW_DESCRIPTION = "Total effort (in minutes) to fix all the issues on the component and therefore to comply to all the requirements.";
+
+ @Before
+ public void setUp() {
+ db.executeInsert("metrics",
+ "uuid", "uuid",
+ "name", "sqale_index",
+ "description", OLD_DESCRIPTION);
+ }
+
+ @Test
+ public void execute_whenExecuted_shouldUpdateSqaleIndexDescription() throws SQLException {
+ assertThat(select()).isEqualTo(OLD_DESCRIPTION);
+ underTest.execute();
+ assertThat(select()).isEqualTo(NEW_DESCRIPTION);
+ }
+
+ @Test
+ public void execute_WhenExecutedTwice_shouldBeReentrant() throws SQLException {
+ assertThat(select()).isEqualTo(OLD_DESCRIPTION);
+ underTest.execute();
+ underTest.execute();
+ assertThat(select()).isEqualTo(NEW_DESCRIPTION);
+ }
+
+ private String select() {
+ return (String) db.selectFirst("SELECT DESCRIPTION FROM metrics WHERE NAME = 'sqale_index'").get("DESCRIPTION");
+ }
+
+}
--- /dev/null
+CREATE TABLE "METRICS"(
+ "UUID" CHARACTER VARYING(40) NOT NULL,
+ "NAME" CHARACTER VARYING(64) NOT NULL,
+ "DESCRIPTION" CHARACTER VARYING(255),
+ "DIRECTION" INTEGER DEFAULT 0 NOT NULL,
+ "DOMAIN" CHARACTER VARYING(64),
+ "SHORT_NAME" CHARACTER VARYING(64),
+ "QUALITATIVE" BOOLEAN DEFAULT FALSE NOT NULL,
+ "VAL_TYPE" CHARACTER VARYING(8),
+ "ENABLED" BOOLEAN DEFAULT TRUE,
+ "WORST_VALUE" DOUBLE PRECISION,
+ "BEST_VALUE" DOUBLE PRECISION,
+ "OPTIMIZED_BEST_VALUE" BOOLEAN,
+ "HIDDEN" BOOLEAN,
+ "DELETE_HISTORICAL_DATA" BOOLEAN,
+ "DECIMAL_SCALE" INTEGER
+);
+ALTER TABLE "METRICS" ADD CONSTRAINT "PK_METRICS" PRIMARY KEY("UUID");
+CREATE UNIQUE INDEX "METRICS_UNIQUE_NAME" ON "METRICS"("NAME" NULLS FIRST);