]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-11310 compress DB migrations adding columns to CE tables
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Tue, 2 Oct 2018 08:49:57 +0000 (10:49 +0200)
committersonartech <sonartech@sonarsource.com>
Wed, 10 Oct 2018 07:23:00 +0000 (09:23 +0200)
24 files changed:
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/AddLastKeyColumnsToCeActivity.java [deleted file]
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/AddMainComponentUuidColumnsToCeActivity.java [deleted file]
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/AddMainComponentUuidColumnsToCeQueue.java [deleted file]
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/AddMainComponentUuidColumnsToCeTable.java [deleted file]
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/DropTmpColumnsToCeActivity.java [deleted file]
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/DropTmpComponentUuidColumnsToCeQueue.java [deleted file]
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/FinalizeMainComponentUuidColumnsToCeActivity.java [new file with mode: 0644]
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/FinalizeMainComponentUuidColumnsToCeQueue.java [new file with mode: 0644]
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/FinalizeMainComponentUuidColumnsToCeTable.java [new file with mode: 0644]
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/FinalizeMainLastKeyColumnsToCeActivity.java [new file with mode: 0644]
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/MakeCeActivityLastKeyColumnsNotNullable.java [deleted file]
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/MakeCeActivityLastKeyColumnsNullable.java [deleted file]
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/PopulateLastKeyColumnsToCeActivity.java [deleted file]
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/PopulateMainComponentUuidColumnsToCeActivity.java [deleted file]
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/PopulateMainComponentUuidColumnsToCeQueue.java [deleted file]
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/PopulateMainComponentUuidColumnsToCeTable.java [deleted file]
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/DbVersion74Test.java
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/FinalizeMainComponentUuidColumnsToCeActivityTest.java [new file with mode: 0644]
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/FinalizeMainComponentUuidColumnsToCeQueueTest.java [new file with mode: 0644]
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/FinalizeMainLastKeyColumnsToCeActivityTest.java [new file with mode: 0644]
server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v74/FinalizeMainComponentUuidColumnsToCeActivityTest/ce_activity.sql [new file with mode: 0644]
server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v74/FinalizeMainComponentUuidColumnsToCeQueueTest/ce_queue.sql [new file with mode: 0644]
server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v74/FinalizeMainLastKeyColumnsToCeActivityTest/ce_activity.sql [new file with mode: 0644]

diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/AddLastKeyColumnsToCeActivity.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/AddLastKeyColumnsToCeActivity.java
deleted file mode 100644 (file)
index 5152685..0000000
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * 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.AddColumnsBuilder;
-import org.sonar.server.platform.db.migration.sql.CreateIndexBuilder;
-import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder;
-import org.sonar.server.platform.db.migration.sql.DropIndexBuilder;
-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.UUID_SIZE;
-import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder;
-
-@SupportsBlueGreen
-public class AddLastKeyColumnsToCeActivity extends DdlChange {
-  private static final String TABLE_NAME = "ce_activity";
-  private static final int TASK_TYPE_COLUMN_SIZE = 15;
-  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(UUID_SIZE + TASK_TYPE_COLUMN_SIZE)
-    .setIsNullable(true)
-    .build();
-  private static final BooleanColumnDef COLUMN_MAIN_IS_LAST = newBooleanColumnDefBuilder()
-    .setColumnName("main_is_last")
-    .setIsNullable(true)
-    .build();
-  private static final VarcharColumnDef COLUMN_MAIN_IS_LAST_KEY = newVarcharColumnDefBuilder()
-    .setColumnName("main_is_last_key")
-    .setLimit(UUID_SIZE + TASK_TYPE_COLUMN_SIZE)
-    .setIsNullable(true)
-    .build();
-  private static final VarcharColumnDef COLUMN_STATUS = newVarcharColumnDefBuilder()
-    .setColumnName("status")
-    .setLimit(15)
-    .setIsNullable(false)
-    .build();
-
-  public AddLastKeyColumnsToCeActivity(Database db) {
-    super(db);
-  }
-
-  @Override
-  public void execute(Context context) throws SQLException {
-    // drop existing column with wrong values
-    context.execute(new DropIndexBuilder(getDialect())
-      .setTable(TABLE_NAME)
-      .setName("ce_activity_islastkey")
-      .build());
-    context.execute(new DropIndexBuilder(getDialect())
-      .setTable(TABLE_NAME)
-      .setName("ce_activity_islast_status")
-      .build());
-    context.execute(new DropColumnsBuilder(getDialect(), TABLE_NAME, COLUMN_IS_LAST.getName(), COLUMN_IS_LAST_KEY.getName())
-      .build());
-
-
-    context.execute(new AddColumnsBuilder(getDialect(), TABLE_NAME)
-      .addColumn(COLUMN_IS_LAST)
-      .addColumn(COLUMN_IS_LAST_KEY)
-      .addColumn(COLUMN_MAIN_IS_LAST)
-      .addColumn(COLUMN_MAIN_IS_LAST_KEY)
-      .build());
-
-    // create indexes
-    context.execute(new CreateIndexBuilder(getDialect())
-      .setTable(TABLE_NAME)
-      .setName(TABLE_NAME + "_islast_key")
-      .addColumn(COLUMN_IS_LAST_KEY)
-      .setUnique(false)
-      .build());
-    context.execute(new CreateIndexBuilder(getDialect())
-      .setTable(TABLE_NAME)
-      .setName(TABLE_NAME + "_islast")
-      .addColumn(COLUMN_IS_LAST)
-      .addColumn(COLUMN_STATUS)
-      .setUnique(false)
-      .build());
-    context.execute(new CreateIndexBuilder(getDialect())
-      .setTable(TABLE_NAME)
-      .setName(TABLE_NAME + "_main_islast_key")
-      .addColumn(COLUMN_MAIN_IS_LAST_KEY)
-      .setUnique(false)
-      .build());
-    context.execute(new CreateIndexBuilder(getDialect())
-      .setTable(TABLE_NAME)
-      .setName(TABLE_NAME + "_main_islast")
-      .addColumn(COLUMN_MAIN_IS_LAST)
-      .addColumn(COLUMN_STATUS)
-      .setUnique(false)
-      .build());
-  }
-}
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/AddMainComponentUuidColumnsToCeActivity.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/AddMainComponentUuidColumnsToCeActivity.java
deleted file mode 100644 (file)
index dc48dad..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * 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 org.sonar.db.Database;
-import org.sonar.server.platform.db.migration.SupportsBlueGreen;
-
-@SupportsBlueGreen
-public class AddMainComponentUuidColumnsToCeActivity extends AddMainComponentUuidColumnsToCeTable {
-
-  public AddMainComponentUuidColumnsToCeActivity(Database db) {
-    super(db, "ce_activity");
-  }
-
-}
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/AddMainComponentUuidColumnsToCeQueue.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/AddMainComponentUuidColumnsToCeQueue.java
deleted file mode 100644 (file)
index e8bedd3..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * 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 org.sonar.db.Database;
-import org.sonar.server.platform.db.migration.SupportsBlueGreen;
-
-@SupportsBlueGreen
-public class AddMainComponentUuidColumnsToCeQueue extends AddMainComponentUuidColumnsToCeTable {
-
-  public AddMainComponentUuidColumnsToCeQueue(Database db) {
-    super(db, "ce_queue");
-  }
-
-}
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/AddMainComponentUuidColumnsToCeTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/AddMainComponentUuidColumnsToCeTable.java
deleted file mode 100644 (file)
index e2e7b5b..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * 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.def.VarcharColumnDef;
-import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder;
-import org.sonar.server.platform.db.migration.sql.CreateIndexBuilder;
-import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder;
-import org.sonar.server.platform.db.migration.sql.DropIndexBuilder;
-import org.sonar.server.platform.db.migration.step.DdlChange;
-
-import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder;
-
-public abstract class AddMainComponentUuidColumnsToCeTable extends DdlChange {
-  private static final VarcharColumnDef COLUMN_COMPONENT_UUID = newVarcharColumnDefBuilder()
-    .setColumnName("component_uuid")
-    .setLimit(VarcharColumnDef.UUID_SIZE)
-    .setIsNullable(true)
-    .build();
-  private static final VarcharColumnDef COLUMN_MAIN_COMPONENT_UUID = newVarcharColumnDefBuilder()
-    .setColumnName("main_component_uuid")
-    .setLimit(VarcharColumnDef.UUID_SIZE)
-    .setIsNullable(true)
-    .build();
-  private final String tableName;
-
-  AddMainComponentUuidColumnsToCeTable(Database db, String tableName) {
-    super(db);
-    this.tableName = tableName;
-  }
-
-  @Override
-  public void execute(Context context) throws SQLException {
-    // drop existing column with wrong values
-    context.execute(new DropIndexBuilder(getDialect())
-      .setTable(tableName)
-      .setName(tableName + "_component_uuid")
-      .build());
-    context.execute(new DropColumnsBuilder(getDialect(), tableName, COLUMN_COMPONENT_UUID.getName())
-      .build());
-
-    // add new columns
-    context.execute(new AddColumnsBuilder(getDialect(), tableName)
-      .addColumn(COLUMN_COMPONENT_UUID)
-      .addColumn(COLUMN_MAIN_COMPONENT_UUID)
-      .build());
-
-    // create indexes
-    context.execute(new CreateIndexBuilder(getDialect())
-      .setTable(tableName)
-      .setName(tableName + "_component")
-      .addColumn(COLUMN_COMPONENT_UUID)
-      .setUnique(false)
-      .build());
-    context.execute(new CreateIndexBuilder(getDialect())
-      .setTable(tableName)
-      .setName(tableName + "_main_component")
-      .addColumn(COLUMN_MAIN_COMPONENT_UUID)
-      .setUnique(false)
-      .build());
-  }
-}
index 90ce65253b47e02acb158847873cfe173dc1cc42..ef613562bd87fad823940e4db09c19d0aaebe948 100644 (file)
@@ -32,22 +32,15 @@ public class DbVersion74 implements DbVersion {
       .add(2302, "Populate IS_AD_HOC in RULES", PopulateIsAdHocOnRules.class)
       .add(2303, "Set IS_EXTERNAL and IS_AD_HOC not nullable in RULES", SetIsExternalAndIsAdHocNotNullableInRules.class)
       .add(2304, "Add ad hoc related columns in RULES_METADATA", AddAdHocColumnsInInRulesMetadata.class)
-      .add(2305, "Add CE_QUEUE.MAIN_COMPONENT_UUID 1/5", AddTmpColumnsToCeQueue.class)
-      .add(2306, "Add CE_ACTIVITY.MAIN_COMPONENT_UUID 1/5", AddTmpColumnsToCeActivity.class)
-      .add(2307, "Populate CE_QUEUE.MAIN_COMPONENT_UUID 2/5", PopulateTmpColumnsToCeQueue.class)
-      .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)
-      .add(2312, "Add CE_QUEUE.MAIN_COMPONENT_UUID 3/5", AddMainComponentUuidColumnsToCeQueue.class)
-      .add(2313, "Add CE_ACTIVITY.MAIN_COMPONENT_UUID 3/5", AddMainComponentUuidColumnsToCeActivity.class)
-      .add(2314, "Add CE_ACTIVITY.MAIN_LAST_KEY 3/6", AddLastKeyColumnsToCeActivity.class)
-      .add(2315, "Populate CE_QUEUE.MAIN_COMPONENT_UUID 4/5", PopulateMainComponentUuidColumnsToCeQueue.class)
-      .add(2316, "Populate CE_ACTIVITY.MAIN_COMPONENT_UUID 4/5", PopulateMainComponentUuidColumnsToCeActivity.class)
-      .add(2317, "Populate CE_ACTIVITY.MAIN_LAST_KEY 4/6", PopulateLastKeyColumnsToCeActivity.class)
-      .add(2318, "Add CE_QUEUE.MAIN_COMPONENT_UUID 5/5", DropTmpComponentUuidColumnsToCeQueue.class)
-      .add(2319, "Add CE_ACTIVITY.MAIN_COMPONENT_UUID 5/5 + Add CE_ACTIVITY.MAIN_LAST_KEY 5/6", DropTmpColumnsToCeActivity.class)
-      .add(2320, "Add CE_ACTIVITY.MAIN_LAST_KEY 6/6", MakeCeActivityLastKeyColumnsNotNullable.class)
+      .add(2312, "Add CE_QUEUE.MAIN_COMPONENT_UUID 1/3", AddTmpColumnsToCeQueue.class)
+      .add(2313, "Add CE_ACTIVITY.MAIN_COMPONENT_UUID 1/3", AddTmpColumnsToCeActivity.class)
+      .add(2314, "Populate CE_QUEUE.MAIN_COMPONENT_UUID 2/3", PopulateTmpColumnsToCeQueue.class)
+      .add(2315, "Populate CE_ACTIVITY.MAIN_COMPONENT_UUID 2/3", PopulateTmpColumnsToCeActivity.class)
+      .add(2316, "Add CE_ACTIVITY.MAIN_LAST_KEY 1/3", AddTmpLastKeyColumnsToCeActivity.class)
+      .add(2317, "Populate CE_ACTIVITY.MAIN_LAST_KEY 2/3", PopulateTmpLastKeyColumnsToCeActivity.class)
+      .add(2318, "Finalize CE_QUEUE.MAIN_COMPONENT_UUID 3/3", FinalizeMainComponentUuidColumnsToCeActivity.class)
+      .add(2319, "Finalize CE_ACTIVITY.MAIN_COMPONENT_UUID 3/3", FinalizeMainComponentUuidColumnsToCeQueue.class)
+      .add(2320, "Finalize CE_ACTIVITY.MAIN_LAST_KEY 3/3", FinalizeMainLastKeyColumnsToCeActivity.class)
     ;
   }
 }
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/DropTmpColumnsToCeActivity.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/DropTmpColumnsToCeActivity.java
deleted file mode 100644 (file)
index 0db3c75..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * 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.sql.DropColumnsBuilder;
-import org.sonar.server.platform.db.migration.sql.DropIndexBuilder;
-import org.sonar.server.platform.db.migration.step.DdlChange;
-
-@SupportsBlueGreen
-public class DropTmpColumnsToCeActivity extends DdlChange {
-  private static final String TABLE_NAME = "ce_activity";
-
-  public DropTmpColumnsToCeActivity(Database db) {
-    super(db);
-  }
-
-  @Override
-  public void execute(Context context) throws SQLException {
-    context.execute(new DropIndexBuilder(getDialect())
-      .setTable(TABLE_NAME)
-      .setName("ce_activity_t_islast_key")
-      .build());
-    context.execute(new DropIndexBuilder(getDialect())
-      .setTable(TABLE_NAME)
-      .setName("ce_activity_t_islast")
-      .build());
-    context.execute(new DropIndexBuilder(getDialect())
-      .setTable(TABLE_NAME)
-      .setName("ce_activity_t_main_islast_key")
-      .build());
-    context.execute(new DropIndexBuilder(getDialect())
-      .setTable(TABLE_NAME)
-      .setName("ce_activity_t_main_islast")
-      .build());
-    context.execute(new DropIndexBuilder(getDialect())
-      .setTable(TABLE_NAME)
-      .setName("ce_activity_tmp_cpnt_uuid")
-      .build());
-    context.execute(new DropIndexBuilder(getDialect())
-      .setTable(TABLE_NAME)
-      .setName("ce_activity_tmp_main_cpnt_uuid")
-      .build());
-
-    context.execute(new DropColumnsBuilder(getDialect(), TABLE_NAME,
-      "tmp_is_last", "tmp_is_last_key", "tmp_main_is_last", "tmp_main_is_last_key",
-      "tmp_component_uuid", "tmp_main_component_uuid")
-        .build());
-  }
-}
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/DropTmpComponentUuidColumnsToCeQueue.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/DropTmpComponentUuidColumnsToCeQueue.java
deleted file mode 100644 (file)
index 21f67a4..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * 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.sql.DropColumnsBuilder;
-import org.sonar.server.platform.db.migration.sql.DropIndexBuilder;
-import org.sonar.server.platform.db.migration.step.DdlChange;
-
-@SupportsBlueGreen
-public class DropTmpComponentUuidColumnsToCeQueue extends DdlChange {
-  private static final String TABLE_NAME = "ce_queue";
-
-  public DropTmpComponentUuidColumnsToCeQueue(Database db) {
-    super(db);
-  }
-
-  @Override
-  public void execute(Context context) throws SQLException {
-    context.execute(new DropIndexBuilder(getDialect())
-      .setTable(TABLE_NAME)
-      .setName("ce_queue_tmp_component_uuid")
-      .build());
-    context.execute(new DropIndexBuilder(getDialect())
-      .setTable(TABLE_NAME)
-      .setName("ce_queue_tmp_main_cmpt_uuid")
-      .build());
-
-    context.execute(new DropColumnsBuilder(getDialect(), TABLE_NAME, "tmp_component_uuid", "tmp_main_component_uuid")
-      .build());
-  }
-}
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/FinalizeMainComponentUuidColumnsToCeActivity.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/FinalizeMainComponentUuidColumnsToCeActivity.java
new file mode 100644 (file)
index 0000000..40623f3
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * 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 org.sonar.db.Database;
+
+public class FinalizeMainComponentUuidColumnsToCeActivity extends FinalizeMainComponentUuidColumnsToCeTable {
+
+  public FinalizeMainComponentUuidColumnsToCeActivity(Database db) {
+    super(db,  "ce_activity");
+  }
+
+}
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/FinalizeMainComponentUuidColumnsToCeQueue.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/FinalizeMainComponentUuidColumnsToCeQueue.java
new file mode 100644 (file)
index 0000000..a32736d
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * 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 org.sonar.db.Database;
+
+public class FinalizeMainComponentUuidColumnsToCeQueue extends FinalizeMainComponentUuidColumnsToCeTable {
+  public FinalizeMainComponentUuidColumnsToCeQueue(Database db) {
+    super(db, "ce_queue");
+  }
+}
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/FinalizeMainComponentUuidColumnsToCeTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/FinalizeMainComponentUuidColumnsToCeTable.java
new file mode 100644 (file)
index 0000000..a1da530
--- /dev/null
@@ -0,0 +1,91 @@
+/*
+ * 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.def.VarcharColumnDef;
+import org.sonar.server.platform.db.migration.sql.CreateIndexBuilder;
+import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder;
+import org.sonar.server.platform.db.migration.sql.DropIndexBuilder;
+import org.sonar.server.platform.db.migration.sql.RenameColumnsBuilder;
+import org.sonar.server.platform.db.migration.step.DdlChange;
+
+import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder;
+
+public abstract class FinalizeMainComponentUuidColumnsToCeTable extends DdlChange {
+  private static final VarcharColumnDef COLUMN_COMPONENT_UUID = newVarcharColumnDefBuilder()
+    .setColumnName("component_uuid")
+    .setLimit(VarcharColumnDef.UUID_SIZE)
+    .setIsNullable(true)
+    .build();
+  private static final VarcharColumnDef COLUMN_MAIN_COMPONENT_UUID = newVarcharColumnDefBuilder()
+    .setColumnName("main_component_uuid")
+    .setLimit(VarcharColumnDef.UUID_SIZE)
+    .setIsNullable(true)
+    .build();
+  private final String tableName;
+
+  FinalizeMainComponentUuidColumnsToCeTable(Database db, String tableName) {
+    super(db);
+    this.tableName = tableName;
+  }
+
+  @Override
+  public void execute(Context context) throws SQLException {
+    // drop index on existing column COMPONENT_UUID
+    context.execute(new DropIndexBuilder(getDialect())
+      .setTable(tableName)
+      .setName(tableName + "_component_uuid")
+      .build());
+    // drop existing column
+    context.execute(new DropColumnsBuilder(getDialect(), tableName, "component_uuid").build());
+
+    // drop indexes on tmp columns
+    context.execute(new DropIndexBuilder(getDialect())
+      .setTable(tableName)
+      .setName(tableName + "_tmp_cpnt_uuid")
+      .build());
+    context.execute(new DropIndexBuilder(getDialect())
+      .setTable(tableName)
+      .setName(tableName + "_tmp_main_cpnt_uuid")
+      .build());
+
+    // rename tmp columns
+    context.execute(new RenameColumnsBuilder(getDialect(), tableName)
+      .renameColumn("tmp_component_uuid", COLUMN_COMPONENT_UUID)
+      .renameColumn("tmp_main_component_uuid", COLUMN_MAIN_COMPONENT_UUID)
+      .build());
+
+    // recreate indexes on renamed columns
+    context.execute(new CreateIndexBuilder(getDialect())
+      .setTable(tableName)
+      .setName(tableName + "_component")
+      .addColumn(COLUMN_COMPONENT_UUID)
+      .setUnique(false)
+      .build());
+    context.execute(new CreateIndexBuilder(getDialect())
+      .setTable(tableName)
+      .setName(tableName + "_main_component")
+      .addColumn(COLUMN_MAIN_COMPONENT_UUID)
+      .setUnique(false)
+      .build());
+  }
+}
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/FinalizeMainLastKeyColumnsToCeActivity.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/FinalizeMainLastKeyColumnsToCeActivity.java
new file mode 100644 (file)
index 0000000..44f61a0
--- /dev/null
@@ -0,0 +1,146 @@
+/*
+ * 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.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.sql.CreateIndexBuilder;
+import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder;
+import org.sonar.server.platform.db.migration.sql.DropIndexBuilder;
+import org.sonar.server.platform.db.migration.sql.RenameColumnsBuilder;
+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.UUID_SIZE;
+import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder;
+
+public class FinalizeMainLastKeyColumnsToCeActivity extends DdlChange {
+  private static final String TABLE_NAME = "ce_activity";
+  private static final int TASK_TYPE_COLUMN_SIZE = 15;
+  private static final BooleanColumnDef COLUMN_IS_LAST = newBooleanColumnDefBuilder()
+    .setColumnName("is_last")
+    .setIsNullable(false)
+    .build();
+  private static final VarcharColumnDef COLUMN_IS_LAST_KEY = newVarcharColumnDefBuilder()
+    .setColumnName("is_last_key")
+    .setLimit(UUID_SIZE + TASK_TYPE_COLUMN_SIZE)
+    .setIsNullable(false)
+    .build();
+  private static final BooleanColumnDef COLUMN_MAIN_IS_LAST = newBooleanColumnDefBuilder()
+    .setColumnName("main_is_last")
+    .setIsNullable(false)
+    .build();
+  private static final VarcharColumnDef COLUMN_MAIN_IS_LAST_KEY = newVarcharColumnDefBuilder()
+    .setColumnName("main_is_last_key")
+    .setLimit(UUID_SIZE + TASK_TYPE_COLUMN_SIZE)
+    .setIsNullable(false)
+    .build();
+  private static final VarcharColumnDef COLUMN_STATUS = newVarcharColumnDefBuilder()
+    .setColumnName("status")
+    .setLimit(15)
+    .setIsNullable(false)
+    .build();
+
+  public FinalizeMainLastKeyColumnsToCeActivity(Database db) {
+    super(db);
+  }
+
+  @Override
+  public void execute(Context context) throws SQLException {
+    // drop index on existing columns
+    context.execute(new DropIndexBuilder(getDialect())
+      .setTable(TABLE_NAME)
+      .setName("ce_activity_islastkey")
+      .build());
+    context.execute(new DropIndexBuilder(getDialect())
+      .setTable(TABLE_NAME)
+      .setName("ce_activity_islast_status")
+      .build());
+
+    // drop existing columns
+    context.execute(new DropColumnsBuilder(getDialect(), TABLE_NAME, COLUMN_IS_LAST.getName(), COLUMN_IS_LAST_KEY.getName())
+      .build());
+
+    // drop index on tmp columns
+    context.execute(new DropIndexBuilder(getDialect())
+      .setTable(TABLE_NAME)
+      .setName("ce_activity_t_islast_key")
+      .build());
+    context.execute(new DropIndexBuilder(getDialect())
+      .setTable(TABLE_NAME)
+      .setName("ce_activity_t_islast")
+      .build());
+    context.execute(new DropIndexBuilder(getDialect())
+      .setTable(TABLE_NAME)
+      .setName("ce_activity_t_main_islast_key")
+      .build());
+    context.execute(new DropIndexBuilder(getDialect())
+      .setTable(TABLE_NAME)
+      .setName("ce_activity_t_main_islast")
+      .build());
+
+    // rename tmp columns
+    context.execute(new RenameColumnsBuilder(getDialect(), TABLE_NAME)
+      .renameColumn("tmp_is_last", COLUMN_IS_LAST)
+      .renameColumn("tmp_is_last_key", COLUMN_IS_LAST_KEY)
+      .renameColumn("tmp_main_is_last", COLUMN_MAIN_IS_LAST)
+      .renameColumn("tmp_main_is_last_key", COLUMN_MAIN_IS_LAST_KEY)
+      .build());
+
+    // make not nullable
+    context.execute(new AlterColumnsBuilder(getDialect(), TABLE_NAME)
+      .updateColumn(COLUMN_IS_LAST)
+      .updateColumn(COLUMN_IS_LAST_KEY)
+      .updateColumn(COLUMN_MAIN_IS_LAST)
+      .updateColumn(COLUMN_MAIN_IS_LAST_KEY)
+      .build());
+
+    // create indexes
+    context.execute(new CreateIndexBuilder(getDialect())
+      .setTable(TABLE_NAME)
+      .setName(TABLE_NAME + "_islast_key")
+      .addColumn(COLUMN_IS_LAST_KEY)
+      .setUnique(false)
+      .build());
+    context.execute(new CreateIndexBuilder(getDialect())
+      .setTable(TABLE_NAME)
+      .setName(TABLE_NAME + "_islast")
+      .addColumn(COLUMN_IS_LAST)
+      .addColumn(COLUMN_STATUS)
+      .setUnique(false)
+      .build());
+    context.execute(new CreateIndexBuilder(getDialect())
+      .setTable(TABLE_NAME)
+      .setName(TABLE_NAME + "_main_islast_key")
+      .addColumn(COLUMN_MAIN_IS_LAST_KEY)
+      .setUnique(false)
+      .build());
+    context.execute(new CreateIndexBuilder(getDialect())
+      .setTable(TABLE_NAME)
+      .setName(TABLE_NAME + "_main_islast")
+      .addColumn(COLUMN_MAIN_IS_LAST)
+      .addColumn(COLUMN_STATUS)
+      .setUnique(false)
+      .build());
+  }
+}
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/MakeCeActivityLastKeyColumnsNotNullable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/MakeCeActivityLastKeyColumnsNotNullable.java
deleted file mode 100644 (file)
index 4480207..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * 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.UUID_SIZE;
-import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder;
-
-@SupportsBlueGreen
-public class MakeCeActivityLastKeyColumnsNotNullable extends DdlChange {
-  private static final String TABLE_NAME = "ce_activity";
-  private static final int TASK_TYPE_COLUMN_SIZE = 15;
-  private static final BooleanColumnDef COLUMN_IS_LAST = newBooleanColumnDefBuilder()
-    .setColumnName("is_last")
-    .setIsNullable(false)
-    .build();
-  private static final VarcharColumnDef COLUMN_IS_LAST_KEY = newVarcharColumnDefBuilder()
-    .setColumnName("is_last_key")
-    .setLimit(UUID_SIZE + TASK_TYPE_COLUMN_SIZE)
-    .setIsNullable(false)
-    .build();
-  private static final BooleanColumnDef COLUMN_MAIN_IS_LAST = newBooleanColumnDefBuilder()
-    .setColumnName("main_is_last")
-    .setIsNullable(false)
-    .build();
-  private static final VarcharColumnDef COLUMN_MAIN_IS_LAST_KEY = newVarcharColumnDefBuilder()
-    .setColumnName("main_is_last_key")
-    .setLimit(UUID_SIZE + TASK_TYPE_COLUMN_SIZE)
-    .setIsNullable(false)
-    .build();
-
-  public MakeCeActivityLastKeyColumnsNotNullable(Database db) {
-    super(db);
-  }
-
-  @Override
-  public void execute(Context context) throws SQLException {
-    context.execute(new AlterColumnsBuilder(getDialect(), TABLE_NAME)
-      .updateColumn(COLUMN_IS_LAST)
-      .updateColumn(COLUMN_IS_LAST_KEY)
-      .updateColumn(COLUMN_MAIN_IS_LAST)
-      .updateColumn(COLUMN_MAIN_IS_LAST_KEY)
-      .build());
-  }
-}
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
deleted file mode 100644 (file)
index fc3b3b3..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * 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());
-  }
-}
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/PopulateLastKeyColumnsToCeActivity.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/PopulateLastKeyColumnsToCeActivity.java
deleted file mode 100644 (file)
index 8fc66f2..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * 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.api.config.Configuration;
-import org.sonar.db.Database;
-import org.sonar.server.platform.db.migration.SupportsBlueGreen;
-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;
-
-@SupportsBlueGreen
-public class PopulateLastKeyColumnsToCeActivity extends DataChange {
-  private static final String TABLE_NAME = "ce_activity";
-
-  private final Configuration configuration;
-
-  public PopulateLastKeyColumnsToCeActivity(Database db, Configuration configuration) {
-    super(db);
-    this.configuration = configuration;
-  }
-
-  @Override
-  protected void execute(Context context) throws SQLException {
-    if (configuration.getBoolean("sonar.sonarcloud.enabled").orElse(false)) {
-      // data migration will be done in background so that interruption of service
-      // is reduced during upgrade
-      return;
-    }
-
-    MassUpdate massUpdate = context.prepareMassUpdate();
-    massUpdate.select("select" +
-      "  ca.uuid, ca.tmp_is_last, ca.tmp_is_last_key, ca.tmp_main_is_last, ca.tmp_main_is_last_key" +
-      " from ce_activity ca" +
-      " where" +
-      "  ca.is_last is null" +
-      "  or ca.is_last_key is null" +
-      "  or ca.main_is_last is null" +
-      "  or ca.main_is_last_key is null");
-    massUpdate.rowPluralName("rows of " + TABLE_NAME);
-    massUpdate.update("update " + TABLE_NAME + " set is_last=?, is_last_key=?, main_is_last=?, main_is_last_key=? where uuid=?");
-    massUpdate.execute(PopulateLastKeyColumnsToCeActivity::handleUpdate);
-  }
-
-  private static boolean handleUpdate(Select.Row row, SqlStatement update) throws SQLException {
-    String uuid = row.getString(1);
-    boolean isLast = row.getBoolean(2);
-    String isLastKey = row.getString(3);
-    boolean mainIsLast = row.getBoolean(2);
-    String mainIsLastKey = row.getString(3);
-
-    update.setBoolean(1, isLast);
-    update.setString(2, isLastKey);
-    update.setBoolean(3, mainIsLast);
-    update.setString(4, mainIsLastKey);
-    update.setString(5, uuid);
-
-    return true;
-  }
-}
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/PopulateMainComponentUuidColumnsToCeActivity.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/PopulateMainComponentUuidColumnsToCeActivity.java
deleted file mode 100644 (file)
index ae2b75f..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * 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.api.config.Configuration;
-import org.sonar.db.Database;
-import org.sonar.server.platform.db.migration.SupportsBlueGreen;
-
-@SupportsBlueGreen
-public class PopulateMainComponentUuidColumnsToCeActivity extends PopulateMainComponentUuidColumnsToCeTable {
-  private final Configuration configuration;
-
-  public PopulateMainComponentUuidColumnsToCeActivity(Database db, Configuration configuration) {
-    super(db, "ce_activity");
-    this.configuration = configuration;
-  }
-
-  @Override
-  protected void execute(Context context) throws SQLException {
-    if (configuration.getBoolean("sonar.sonarcloud.enabled").orElse(false)) {
-      // data migration will be done in background so that interruption of service
-      // is reduced during upgrade
-      return;
-    }
-
-    super.execute(context);
-  }
-}
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/PopulateMainComponentUuidColumnsToCeQueue.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/PopulateMainComponentUuidColumnsToCeQueue.java
deleted file mode 100644 (file)
index 2fae863..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * 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 org.sonar.db.Database;
-import org.sonar.server.platform.db.migration.SupportsBlueGreen;
-
-@SupportsBlueGreen
-public class PopulateMainComponentUuidColumnsToCeQueue extends PopulateMainComponentUuidColumnsToCeTable {
-
-  public PopulateMainComponentUuidColumnsToCeQueue(Database db) {
-    super(db, "ce_queue");
-  }
-
-}
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/PopulateMainComponentUuidColumnsToCeTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v74/PopulateMainComponentUuidColumnsToCeTable.java
deleted file mode 100644 (file)
index b59af21..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * 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.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 abstract class PopulateMainComponentUuidColumnsToCeTable extends DataChange {
-  protected final String tableName;
-
-  PopulateMainComponentUuidColumnsToCeTable(Database db, String tableName) {
-    super(db);
-    this.tableName = tableName;
-  }
-
-  @Override
-  protected void execute(Context context) throws SQLException {
-    MassUpdate massUpdate = context.prepareMassUpdate();
-    massUpdate.select("select" +
-      "  c.uuid, c.tmp_component_uuid, c.tmp_main_component_uuid" +
-      " from " + tableName + " c" +
-      " where" +
-      "  c.tmp_component_uuid is not null" +
-      "  and (c.component_uuid is null or c.main_component_uuid is null)");
-    massUpdate.rowPluralName("tasks with component");
-    massUpdate.update("update " + tableName + " set component_uuid=?, main_component_uuid=? where uuid=?");
-    massUpdate.execute(PopulateMainComponentUuidColumnsToCeTable::handleUpdate);
-  }
-
-  private static boolean handleUpdate(Select.Row row, SqlStatement update) throws SQLException {
-    String uuid = row.getString(1);
-    String componentUuuid = row.getString(2);
-    String mainComponentUuuid = row.getString(3);
-
-    update.setString(1, componentUuuid);
-    update.setString(2, mainComponentUuuid);
-    update.setString(3, uuid);
-
-    return true;
-  }
-}
index d60e9a69c4eea5541b20a639209a4932f0776a27..7ba5fae6ba54b69529ada139097707e378ba41e4 100644 (file)
@@ -35,6 +35,6 @@ public class DbVersion74Test {
 
   @Test
   public void verify_migration_count() {
-    verifyMigrationCount(underTest, 21);
+    verifyMigrationCount(underTest, 14);
   }
 }
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/FinalizeMainComponentUuidColumnsToCeActivityTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/FinalizeMainComponentUuidColumnsToCeActivityTest.java
new file mode 100644 (file)
index 0000000..6dd7d1d
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * 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.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.sonar.db.CoreDbTester;
+
+import static java.sql.Types.VARCHAR;
+
+public class FinalizeMainComponentUuidColumnsToCeActivityTest {
+  private static final String TABLE_NAME = "ce_activity";
+
+  @Rule
+  public final CoreDbTester db = CoreDbTester.createForSchema(FinalizeMainComponentUuidColumnsToCeActivityTest.class, "ce_activity.sql");
+  @Rule
+  public ExpectedException expectedException = ExpectedException.none();
+
+  private FinalizeMainComponentUuidColumnsToCeActivity underTest = new FinalizeMainComponentUuidColumnsToCeActivity(db.database());
+
+  @Test
+  public void columns_and_indexes_are_added_to_table() throws SQLException {
+    underTest.execute();
+
+    db.assertColumnDoesNotExist(TABLE_NAME, "tmp_component_uuid");
+    db.assertColumnDoesNotExist(TABLE_NAME, "tmp_main_component_uuid");
+    db.assertIndexDoesNotExist(TABLE_NAME, "ce_activity_tmp_cmpt_uuid");
+    db.assertIndexDoesNotExist(TABLE_NAME, "ce_activity_tmp_main_cmpt_uuid");
+    db.assertColumnDefinition(TABLE_NAME, "component_uuid", VARCHAR, 40, true);
+    db.assertColumnDefinition(TABLE_NAME, "main_component_uuid", VARCHAR, 40, true);
+    db.assertIndex(TABLE_NAME, "ce_activity_component", "component_uuid");
+    db.assertIndex(TABLE_NAME, "ce_activity_main_component", "main_component_uuid");
+  }
+
+  @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/v74/FinalizeMainComponentUuidColumnsToCeQueueTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/FinalizeMainComponentUuidColumnsToCeQueueTest.java
new file mode 100644 (file)
index 0000000..c05f60e
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * 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.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.sonar.db.CoreDbTester;
+
+import static java.sql.Types.VARCHAR;
+
+public class FinalizeMainComponentUuidColumnsToCeQueueTest {
+  private static final String TABLE_NAME = "ce_queue";
+
+  @Rule
+  public final CoreDbTester db = CoreDbTester.createForSchema(FinalizeMainComponentUuidColumnsToCeQueueTest.class, "ce_queue.sql");
+  @Rule
+  public ExpectedException expectedException = ExpectedException.none();
+
+  private FinalizeMainComponentUuidColumnsToCeQueue underTest = new FinalizeMainComponentUuidColumnsToCeQueue(db.database());
+
+  @Test
+  public void columns_and_indexes_are_added_to_table() throws SQLException {
+    underTest.execute();
+
+    db.assertColumnDoesNotExist(TABLE_NAME, "tmp_component_uuid");
+    db.assertColumnDoesNotExist(TABLE_NAME, "tmp_main_component_uuid");
+    db.assertIndexDoesNotExist(TABLE_NAME, "ce_queue_tmp_cmpt_uuid");
+    db.assertIndexDoesNotExist(TABLE_NAME, "ce_queue_tmp_main_cmpt_uuid");
+    db.assertColumnDefinition(TABLE_NAME, "component_uuid", VARCHAR, 40, true);
+    db.assertColumnDefinition(TABLE_NAME, "main_component_uuid", VARCHAR, 40, true);
+    db.assertIndex(TABLE_NAME, "ce_queue_component", "component_uuid");
+    db.assertIndex(TABLE_NAME, "ce_queue_main_component", "main_component_uuid");
+  }
+
+  @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/v74/FinalizeMainLastKeyColumnsToCeActivityTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v74/FinalizeMainLastKeyColumnsToCeActivityTest.java
new file mode 100644 (file)
index 0000000..0ba21e5
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+ * 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.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.sonar.db.CoreDbTester;
+
+import static java.sql.Types.BOOLEAN;
+import static java.sql.Types.VARCHAR;
+
+public class FinalizeMainLastKeyColumnsToCeActivityTest {
+  private static final String TABLE_NAME = "ce_activity";
+
+  @Rule
+  public final CoreDbTester db = CoreDbTester.createForSchema(FinalizeMainLastKeyColumnsToCeActivityTest.class, "ce_activity.sql");
+  @Rule
+  public ExpectedException expectedException = ExpectedException.none();
+
+  private FinalizeMainLastKeyColumnsToCeActivity underTest = new FinalizeMainLastKeyColumnsToCeActivity(db.database());
+
+  @Test
+  public void columns_and_indexes_are_added_to_table() throws SQLException {
+    underTest.execute();
+
+    db.assertColumnDoesNotExist(TABLE_NAME, "tmp_is_last");
+    db.assertColumnDoesNotExist(TABLE_NAME, "tmp_is_last_key");
+    db.assertColumnDoesNotExist(TABLE_NAME, "tmp_main_is_last");
+    db.assertColumnDoesNotExist(TABLE_NAME, "tmp_main_is_last_key");
+    db.assertIndexDoesNotExist(TABLE_NAME, "ce_activity_t_islast_key");
+    db.assertIndexDoesNotExist(TABLE_NAME, "ce_activity_t_islast");
+    db.assertIndexDoesNotExist(TABLE_NAME, "ce_activity_t_main_islast_key");
+    db.assertIndexDoesNotExist(TABLE_NAME, "ce_activity_t_main_islast");
+    db.assertColumnDefinition(TABLE_NAME, "is_last", BOOLEAN, null, false);
+    db.assertColumnDefinition(TABLE_NAME, "is_last_key", VARCHAR, 55, false);
+    db.assertColumnDefinition(TABLE_NAME, "main_is_last", BOOLEAN, null, false);
+    db.assertColumnDefinition(TABLE_NAME, "main_is_last_key", VARCHAR, 55, false);
+    db.assertIndex(TABLE_NAME, "ce_activity_islast_key", "is_last_key");
+    db.assertIndex(TABLE_NAME, "ce_activity_islast", "is_last", "status");
+    db.assertIndex(TABLE_NAME, "ce_activity_main_islast_key", "main_is_last_key");
+    db.assertIndex(TABLE_NAME, "ce_activity_main_islast", "main_is_last", "status");
+  }
+
+  @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/resources/org/sonar/server/platform/db/migration/version/v74/FinalizeMainComponentUuidColumnsToCeActivityTest/ce_activity.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v74/FinalizeMainComponentUuidColumnsToCeActivityTest/ce_activity.sql
new file mode 100644 (file)
index 0000000..b4e110b
--- /dev/null
@@ -0,0 +1,38 @@
+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,
+  "TMP_COMPONENT_UUID" VARCHAR(40) NULL,
+  "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,
+  "TMP_IS_LAST" BOOLEAN,
+  "TMP_IS_LAST_KEY" VARCHAR(55),
+  "TMP_MAIN_IS_LAST" BOOLEAN,
+  "TMP_MAIN_IS_LAST_KEY" VARCHAR(55),
+  "SUBMITTER_UUID" 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,
+  "ERROR_TYPE" VARCHAR(20)
+);
+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_TMP_CPNT_UUID" ON "CE_ACTIVITY" ("TMP_COMPONENT_UUID");
+CREATE INDEX "CE_ACTIVITY_TMP_MAIN_CPNT_UUID" ON "CE_ACTIVITY" ("TMP_MAIN_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 INDEX "CE_ACTIVITY_T_ISLAST_KEY" ON "CE_ACTIVITY" ("TMP_IS_LAST_KEY");
+CREATE INDEX "CE_ACTIVITY_T_ISLAST" ON "CE_ACTIVITY" ("TMP_IS_LAST", "STATUS");
+CREATE INDEX "CE_ACTIVITY_T_MAIN_ISLAST_KEY" ON "CE_ACTIVITY" ("TMP_MAIN_IS_LAST_KEY");
+CREATE INDEX "CE_ACTIVITY_T_MAIN_ISLAST" ON "CE_ACTIVITY" ("TMP_MAIN_IS_LAST", "STATUS");
diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v74/FinalizeMainComponentUuidColumnsToCeQueueTest/ce_queue.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v74/FinalizeMainComponentUuidColumnsToCeQueueTest/ce_queue.sql
new file mode 100644 (file)
index 0000000..c42f2cb
--- /dev/null
@@ -0,0 +1,20 @@
+CREATE TABLE "CE_QUEUE" (
+  "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,
+  "TMP_COMPONENT_UUID" VARCHAR(40) NULL,
+  "TMP_MAIN_COMPONENT_UUID" VARCHAR(40) NULL,
+  "STATUS" VARCHAR(15) NOT NULL,
+  "SUBMITTER_UUID" VARCHAR(255) NULL,
+  "WORKER_UUID" VARCHAR(40) NULL,
+  "EXECUTION_COUNT" INTEGER NOT NULL,
+  "STARTED_AT" BIGINT NULL,
+  "CREATED_AT" BIGINT NOT NULL,
+  "UPDATED_AT" BIGINT NOT NULL
+);
+CREATE UNIQUE INDEX "CE_QUEUE_UUID" ON "CE_QUEUE" ("UUID");
+CREATE INDEX "CE_QUEUE_COMPONENT_UUID" ON "CE_QUEUE" ("COMPONENT_UUID");
+CREATE INDEX "CE_QUEUE_TMP_CPNT_UUID" ON "CE_QUEUE" ("TMP_COMPONENT_UUID");
+CREATE INDEX "CE_QUEUE_TMP_MAIN_CPNT_UUID" ON "CE_QUEUE" ("TMP_MAIN_COMPONENT_UUID");
+CREATE INDEX "CE_QUEUE_STATUS" ON "CE_QUEUE" ("STATUS");
diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v74/FinalizeMainLastKeyColumnsToCeActivityTest/ce_activity.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v74/FinalizeMainLastKeyColumnsToCeActivityTest/ce_activity.sql
new file mode 100644 (file)
index 0000000..4dfeabe
--- /dev/null
@@ -0,0 +1,36 @@
+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,
+  "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,
+  "TMP_IS_LAST" BOOLEAN,
+  "TMP_IS_LAST_KEY" VARCHAR(55),
+  "TMP_MAIN_IS_LAST" BOOLEAN,
+  "TMP_MAIN_IS_LAST_KEY" VARCHAR(55),
+  "SUBMITTER_UUID" 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,
+  "ERROR_TYPE" VARCHAR(20)
+);
+CREATE UNIQUE INDEX "CE_ACTIVITY_UUID" ON "CE_ACTIVITY" ("UUID");
+CREATE INDEX "CE_ACTIVITY_COMPONENT" ON "CE_ACTIVITY" ("COMPONENT_UUID");
+CREATE INDEX "CE_ACTIVITY_MAIN_COMPONENT" 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 INDEX "CE_ACTIVITY_T_ISLAST_KEY" ON "CE_ACTIVITY" ("TMP_IS_LAST_KEY");
+CREATE INDEX "CE_ACTIVITY_T_ISLAST" ON "CE_ACTIVITY" ("TMP_IS_LAST", "STATUS");
+CREATE INDEX "CE_ACTIVITY_T_MAIN_ISLAST_KEY" ON "CE_ACTIVITY" ("TMP_MAIN_IS_LAST_KEY");
+CREATE INDEX "CE_ACTIVITY_T_MAIN_ISLAST" ON "CE_ACTIVITY" ("TMP_MAIN_IS_LAST", "STATUS");