]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-9043 Drop database column PROJECT_MEASURES.DESCRIPTION
authorDuarte Meneses <duarte.meneses@sonarsource.com>
Mon, 8 Feb 2021 22:04:30 +0000 (16:04 -0600)
committersonartech <sonartech@sonarsource.com>
Wed, 10 Feb 2021 20:07:17 +0000 (20:07 +0000)
server/sonar-db-dao/src/schema/schema-sq.ddl
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v87/DbVersion87.java
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v87/DropDescriptionInProjectMeasures.java [new file with mode: 0644]
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v87/DropDescriptionInProjectMeasuresTest.java [new file with mode: 0644]
server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v87/DropDescriptionInProjectMeasuresTest/schema.sql [new file with mode: 0644]

index cda3c17c248a69e80f655e0a46feb3821cf70bfc..35c44d970c069a6405bede4b0c2fcd0114428ba4 100644 (file)
@@ -626,7 +626,6 @@ CREATE TABLE "PROJECT_MEASURES"(
     "TEXT_VALUE" VARCHAR(4000),
     "ALERT_STATUS" VARCHAR(5),
     "ALERT_TEXT" VARCHAR(4000),
-    "DESCRIPTION" VARCHAR(4000),
     "PERSON_ID" INTEGER,
     "VARIATION_VALUE_1" DOUBLE,
     "MEASURE_DATA" BLOB,
index fc4c4de15bb36ea976779409cdd1bc44bbff25ea..700e6606dc0d447f06ca659e17a42577b9a8c4c6 100644 (file)
@@ -43,6 +43,9 @@ public class DbVersion87 implements DbVersion {
       .add(4210, "Add column 'monorepo' to table 'project_alm_settings'", AddMonorepoColumnToProjectAlmSettingsTable.class)
       .add(4211, "Populate column 'monorepo' to false in table 'project_alm_settings'", PopulateMonorepoColumnToProjectAlmSettingsTable.class)
       .add(4212, "Make column 'monorepo' in table 'project_alm_settings' not Nullable", MakeMonorepoColumnInProjectAlmSettingsTableNotNullable.class)
+
+      .add(4213, "Drop column 'description' in table 'project_measures'", DropDescriptionInProjectMeasures.class)
+
     ;
   }
 }
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v87/DropDescriptionInProjectMeasures.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v87/DropDescriptionInProjectMeasures.java
new file mode 100644 (file)
index 0000000..898f413
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * 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.v87;
+
+import java.sql.SQLException;
+import org.sonar.db.Database;
+import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder;
+import org.sonar.server.platform.db.migration.step.DdlChange;
+
+public class DropDescriptionInProjectMeasures extends DdlChange {
+  private static final String TABLE_NAME = "project_measures";
+
+  public DropDescriptionInProjectMeasures(Database db) {
+    super(db);
+  }
+
+  @Override
+  public void execute(Context context) throws SQLException {
+    context.execute(new DropColumnsBuilder(getDialect(), TABLE_NAME, "description").build());
+  }
+}
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v87/DropDescriptionInProjectMeasuresTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v87/DropDescriptionInProjectMeasuresTest.java
new file mode 100644 (file)
index 0000000..dfa0788
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * 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.v87;
+
+import java.sql.SQLException;
+import org.junit.Rule;
+import org.junit.Test;
+import org.sonar.db.CoreDbTester;
+import org.sonar.server.platform.db.migration.step.MigrationStep;
+
+public class DropDescriptionInProjectMeasuresTest {
+
+  @Rule
+  public CoreDbTester dbTester = CoreDbTester.createForSchema(DropDescriptionInProjectMeasuresTest.class, "schema.sql");
+
+  private MigrationStep underTest = new DropDescriptionInProjectMeasures(dbTester.database());
+
+  @Test
+  public void column_has_been_dropped() throws SQLException {
+    underTest.execute();
+    dbTester.assertColumnDoesNotExist("project_measures", "description");
+  }
+}
diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v87/DropDescriptionInProjectMeasuresTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v87/DropDescriptionInProjectMeasuresTest/schema.sql
new file mode 100644 (file)
index 0000000..87fb2c6
--- /dev/null
@@ -0,0 +1,17 @@
+CREATE TABLE "PROJECT_MEASURES"(
+    "VALUE" DOUBLE,
+    "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,
+    "MEASURE_DATA" BLOB,
+    "UUID" VARCHAR(40) NOT NULL,
+    "METRIC_UUID" VARCHAR(40) NOT NULL
+);
+ALTER TABLE "PROJECT_MEASURES" ADD CONSTRAINT "PK_PROJECT_MEASURES" PRIMARY KEY("UUID");
+CREATE INDEX "MEASURES_COMPONENT_UUID" ON "PROJECT_MEASURES"("COMPONENT_UUID");
+CREATE INDEX "MEASURES_ANALYSIS_METRIC" ON "PROJECT_MEASURES"("ANALYSIS_UUID", "METRIC_UUID");