]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-11310 drop usages of CE_*.COMPONENT_UUID, CE_ACTIVITY.IS_LAST*
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Mon, 1 Oct 2018 13:14:33 +0000 (15:14 +0200)
committerSonarTech <sonartech@sonarsource.com>
Thu, 4 Oct 2018 18:20:57 +0000 (20:20 +0200)
server/sonar-db-core/src/main/resources/org/sonar/db/version/schema-h2.ddl
server/sonar-db-dao/src/main/resources/org/sonar/db/ce/CeActivityMapper.xml
server/sonar-db-dao/src/main/resources/org/sonar/db/ce/CeQueueMapper.xml
server/sonar-db-dao/src/test/java/org/sonar/db/purge/PurgeDaoTest.java
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/DbVersion74.java
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/MakeCeActivityLastKeyColumnsNullable.java [new file with mode: 0644]
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/DbVersion74Test.java

index ed0e309f56e610ad3fcac17e6eca39db0cf68798..81a1b3b17a08d63ef98924c29b6c78e283840a2b 100644 (file)
@@ -695,8 +695,8 @@ CREATE TABLE "CE_ACTIVITY" (
   "TMP_MAIN_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,
+  "IS_LAST" BOOLEAN,
+  "IS_LAST_KEY" VARCHAR(55),
   "TMP_IS_LAST" BOOLEAN,
   "TMP_IS_LAST_KEY" VARCHAR(55),
   "TMP_MAIN_IS_LAST" BOOLEAN,
index 69c6504dead4efe931f8a6004ac5955420e9a270..b5be2b8d9aa1edd35a3c7c3d3197e2003627de44 100644 (file)
       uuid,
       tmp_component_uuid,
       tmp_main_component_uuid,
-      component_uuid,
       analysis_uuid,
       status,
       task_type,
       tmp_is_last_key,
       tmp_main_is_last,
       tmp_main_is_last_key,
-      is_last,
-      is_last_key,
       submitter_uuid,
       submitted_at,
       worker_uuid,
       #{uuid,jdbcType=VARCHAR},
       #{componentUuid,jdbcType=VARCHAR},
       #{mainComponentUuid,jdbcType=VARCHAR},
-      #{mainComponentUuid,jdbcType=VARCHAR},
       #{analysisUuid,jdbcType=VARCHAR},
       #{status,jdbcType=VARCHAR},
       #{taskType,jdbcType=VARCHAR},
       #{isLastKey,jdbcType=VARCHAR},
       #{mainIsLast,jdbcType=BOOLEAN},
       #{mainIsLastKey,jdbcType=VARCHAR},
-      #{mainIsLast,jdbcType=BOOLEAN},
-      #{mainIsLastKey,jdbcType=VARCHAR},
       #{submitterUuid,jdbcType=VARCHAR},
       #{submittedAt,jdbcType=BIGINT},
       #{workerUuid,jdbcType=VARCHAR},
     update ce_activity set
       tmp_is_last=${_false},
       tmp_main_is_last=${_false},
-      is_last=${_false},
       updated_at=#{updatedAt,jdbcType=BIGINT}
     where
       (tmp_is_last=${_true} and tmp_is_last_key=#{isLastKey,jdbcType=VARCHAR})
index 6eab90a67f8e79c2032a8912af04782cb039082a..3135f04da1655183d83892fe1ec02a1c11ed22ce 100644 (file)
       uuid,
       task_type,
       tmp_component_uuid,
-      component_uuid,
       tmp_main_component_uuid,
       status,
       submitter_uuid,
       #{taskType,jdbcType=VARCHAR},
       #{componentUuid,jdbcType=VARCHAR},
       #{mainComponentUuid,jdbcType=VARCHAR},
-      #{mainComponentUuid,jdbcType=VARCHAR},
       #{status,jdbcType=VARCHAR},
       #{submitterUuid,jdbcType=VARCHAR},
       0,
index eb060efb539ee384bd4e0be9c85522232adc7d4d..616c40056745b11c36ce1417ad62b36052484c7b 100644 (file)
@@ -414,7 +414,7 @@ public class PurgeDaoTest {
     dbSession.commit();
 
     assertThat(db.countRowsOfTable("ce_queue")).isEqualTo(1);
-    assertThat(db.countSql("select count(*) from ce_queue where component_uuid='" + projectToBeDeleted.uuid() + "'")).isEqualTo(0);
+    assertThat(db.countSql("select count(*) from ce_queue where tmp_main_component_uuid='" + projectToBeDeleted.uuid() + "'")).isEqualTo(0);
   }
 
   @Test
index 82b34413d0ba4fc6f60513113424d3ebe3439e5b..642e3ef57f359661ccd03e68f2cbcc6d154786f9 100644 (file)
@@ -38,6 +38,7 @@ public class DbVersion74 implements DbVersion {
       .add(2308, "Populate CE_ACTIVITY.MAIN_COMPONENT_UUID 2/5", PopulateTmpColumnsToCeActivity.class)
       .add(2309, "Add CE_ACTIVITY.MAIN_LAST_KEY 1/6", AddTmpLastKeyColumnsToCeActivity.class)
       .add(2310, "Populate CE_ACTIVITY.MAIN_LAST_KEY 2/6", PopulateTmpLastKeyColumnsToCeActivity.class)
+      .add(2311, "Populate CE_ACTIVITY.MAIN_LAST_KEY 3/6", MakeCeActivityLastKeyColumnsNullable.class)
     ;
   }
 }
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/MakeCeActivityLastKeyColumnsNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/MakeCeActivityLastKeyColumnsNullable.java
new file mode 100644 (file)
index 0000000..fc3b3b3
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2018 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.v74;
+
+import java.sql.SQLException;
+import org.sonar.db.Database;
+import org.sonar.server.platform.db.migration.SupportsBlueGreen;
+import org.sonar.server.platform.db.migration.def.BooleanColumnDef;
+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;
+
+import static org.sonar.server.platform.db.migration.def.BooleanColumnDef.newBooleanColumnDefBuilder;
+import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder;
+
+@SupportsBlueGreen
+public class MakeCeActivityLastKeyColumnsNullable extends DdlChange {
+  private static final BooleanColumnDef COLUMN_IS_LAST = newBooleanColumnDefBuilder()
+    .setColumnName("is_last")
+    .setIsNullable(true)
+    .build();
+  private static final VarcharColumnDef COLUMN_IS_LAST_KEY = newVarcharColumnDefBuilder()
+    .setColumnName("is_last_key")
+    .setLimit(55)
+    .setIsNullable(true)
+    .build();
+
+  public MakeCeActivityLastKeyColumnsNullable(Database db) {
+    super(db);
+  }
+
+  @Override
+  public void execute(Context context) throws SQLException {
+    context.execute(new AlterColumnsBuilder(getDialect(), "ce_activity")
+      .updateColumn(COLUMN_IS_LAST)
+      .updateColumn(COLUMN_IS_LAST_KEY)
+      .build());
+  }
+}
index c0ba8282e1c681e73c9f39e732e97a58c37d0090..7f5028ad33218249e03cfcc37d0f559c72d4d84a 100644 (file)
@@ -35,6 +35,6 @@ public class DbVersion74Test {
 
   @Test
   public void verify_migration_count() {
-    verifyMigrationCount(underTest, 11);
+    verifyMigrationCount(underTest, 12);
   }
 }