]> source.dussan.org Git - sonarqube.git/commitdiff
Revert "Migrate drop of PR columns for Next"
authorDuarte Meneses <duarte.meneses@sonarsource.com>
Thu, 5 Oct 2017 09:31:47 +0000 (11:31 +0200)
committerDuarte Meneses <duarte.meneses@sonarsource.com>
Mon, 9 Oct 2017 09:47:35 +0000 (11:47 +0200)
This reverts commit eec858d104870f435a5085324faace11c125690e.

server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/CreateTableProjectBranches.java
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/DbVersion66.java
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/DropPrColumnsFromProjectBranches.java [deleted file]
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/PopulateMainProjectBranches.java
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v66/DbVersion66Test.java
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v66/DropPrColumnsFromProjectBranchesTest.java [deleted file]
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v66/PopulateMainProjectBranchesTest.java
server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v66/DropPrColumnsFromProjectBranchesTest/initial.sql [deleted file]
server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v66/PopulateMainProjectBranchesTest/initial.sql

index db40d988aecf4caf8b7747f371178e612325429d..072e2cf428b414d32064663f24d92150fe67b416 100644 (file)
@@ -47,11 +47,6 @@ public class CreateTableProjectBranches extends DdlChange {
         .setIsNullable(false)
         .setLimit(50)
         .build())
-      .addColumn(VarcharColumnDef.newVarcharColumnDefBuilder()
-        .setColumnName("kee_type")
-        .setIsNullable(false)
-        .setLimit(6)
-        .build())
       .addColumn(VarcharColumnDef.newVarcharColumnDefBuilder()
         .setColumnName("kee")
         .setIsNullable(false)
@@ -67,11 +62,6 @@ public class CreateTableProjectBranches extends DdlChange {
         .setIsNullable(true)
         .setLimit(50)
         .build())
-      .addColumn(VarcharColumnDef.newVarcharColumnDefBuilder()
-        .setColumnName("pull_request_title")
-        .setIsNullable(true)
-        .setLimit(4000)
-        .build())
       .addColumn(BigIntegerColumnDef.newBigIntegerColumnDefBuilder()
         .setColumnName("created_at")
         .setIsNullable(false)
index 6ab87afd264585ca57f31bb09ab6d0c8fced4775..a2261eeab125e447bc4af66051aa1acae82ad640 100644 (file)
@@ -39,7 +39,6 @@ public class DbVersion66 implements DbVersion {
       .add(1810, "Add ce_activity.error_type", AddErrorTypeColumnToCeActivityTable.class)
       .add(1811, "Create table qprofile_edit_users", CreateTableQProfileEditUsers.class)
       .add(1812, "Create table qprofile_edit_groups", CreateTableQProfileEditGroups.class)
-      .add(1813, "Drop PR columns from project_branches", DropPrColumnsFromProjectBranches.class)
       .add(1814, "Purge table properties", PurgeTableProperties.class)
     ;
   }
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/DropPrColumnsFromProjectBranches.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/DropPrColumnsFromProjectBranches.java
deleted file mode 100644 (file)
index d8a62e1..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 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.v66;
-
-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.step.DdlChange;
-
-public class DropPrColumnsFromProjectBranches extends DdlChange {
-  static final String PROJECT_BRANCHES_TABLE_NAME = "project_branches";
-
-  public DropPrColumnsFromProjectBranches(Database db) {
-    super(db);
-  }
-
-  @Override
-  public void execute(Context context) throws SQLException {
-    context.execute(new DropIndexBuilder(getDialect()).setTable(PROJECT_BRANCHES_TABLE_NAME).setName("project_branches_kee").build());
-    context.execute(new DropColumnsBuilder(getDialect(), PROJECT_BRANCHES_TABLE_NAME, "kee_type", "pull_request_title").build());
-    context.execute(
-      new CreateIndexBuilder(getDialect())
-        .setTable(PROJECT_BRANCHES_TABLE_NAME)
-        .setName("project_branches_kee")
-        .setUnique(true)
-        .addColumn(VarcharColumnDef.newVarcharColumnDefBuilder()
-          .setColumnName("project_uuid")
-          .setIsNullable(false)
-          .setLimit(50)
-          .build())
-        .addColumn(VarcharColumnDef.newVarcharColumnDefBuilder()
-          .setColumnName("kee")
-          .setIsNullable(false)
-          .setLimit(255)
-          .build())
-        .build());
-  }
-
-}
index 9d66de5abdca307411527e526a72e59b355cc4b0..77fca273828077030bbdc918bae7b9bc2d97ce3c 100644 (file)
@@ -43,20 +43,18 @@ public class PopulateMainProjectBranches extends DataChange {
     massUpdate.select("SELECT uuid FROM projects p "
       + "WHERE p.scope='PRJ' AND p.qualifier='TRK' AND p.main_branch_project_uuid IS NULL "
       + "AND NOT EXISTS (SELECT uuid FROM project_branches b WHERE b.uuid = p.uuid)");
-    massUpdate.update("INSERT INTO project_branches (uuid, project_uuid, kee_type, kee, branch_type, "
-      + "merge_branch_uuid, pull_request_title, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)");
+    massUpdate.update("INSERT INTO project_branches (uuid, project_uuid, kee, branch_type, "
+      + "merge_branch_uuid, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?)");
     massUpdate.rowPluralName("projects");
     massUpdate.execute((row, update) -> {
       String uuid = row.getString(1);
       update.setString(1, uuid);
       update.setString(2, uuid);
-      update.setString(3, "BRANCH");
-      update.setString(4, MAIN_BRANCH_NAME);
-      update.setString(5, "LONG");
-      update.setString(6, null);
-      update.setString(7, null);
-      update.setLong(8, now);
-      update.setLong(9, now);
+      update.setString(3, MAIN_BRANCH_NAME);
+      update.setString(4, "LONG");
+      update.setString(5, null);
+      update.setLong(6, now);
+      update.setLong(7, now);
       return true;
     });
   }
index 073819a0ee4b86405311774d5c25f1c778748fe3..de7450360cfbb85e98a3f3c1c783074f6043be0c 100644 (file)
@@ -36,7 +36,7 @@ public class DbVersion66Test {
 
   @Test
   public void verify_migration_count() {
-    verifyMigrationCount(underTest, 14);
+    verifyMigrationCount(underTest, 13);
   }
 
 }
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v66/DropPrColumnsFromProjectBranchesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v66/DropPrColumnsFromProjectBranchesTest.java
deleted file mode 100644 (file)
index 8d71727..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 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.v66;
-
-import java.sql.SQLException;
-import org.junit.Rule;
-import org.junit.Test;
-import org.sonar.db.CoreDbTester;
-
-import static org.sonar.server.platform.db.migration.version.v66.DropPrColumnsFromProjectBranches.PROJECT_BRANCHES_TABLE_NAME;
-
-public class DropPrColumnsFromProjectBranchesTest {
-  @Rule
-  public CoreDbTester db = CoreDbTester.createForSchema(DropPrColumnsFromProjectBranchesTest.class, "initial.sql");
-
-  private DropPrColumnsFromProjectBranches underTest = new DropPrColumnsFromProjectBranches(db.database());
-
-  @Test
-  public void drop_columns() throws SQLException {
-    underTest.execute();
-    db.assertColumnDoesNotExist(PROJECT_BRANCHES_TABLE_NAME, "kee_type");
-    db.assertColumnDoesNotExist(PROJECT_BRANCHES_TABLE_NAME, "pull_request_title");
-    db.assertUniqueIndex(PROJECT_BRANCHES_TABLE_NAME, "project_branches_kee", "project_uuid", "kee");
-  }
-}
index 29433a7dc19d18095ab49660c8da7d6e1b7cda95..e9a10caa2d82975f65740efb83909b36e39c7a84 100644 (file)
@@ -54,7 +54,7 @@ public class PopulateMainProjectBranchesTest {
 
     underTest.execute();
 
-    assertProjectBranches(tuple("master", project, project, "BRANCH", "LONG", NOW, NOW));
+    assertProjectBranches(tuple("master", project, project, "LONG", NOW, NOW));
   }
 
   @Test
@@ -81,13 +81,13 @@ public class PopulateMainProjectBranchesTest {
 
     underTest.execute();
 
-    assertProjectBranches(tuple("master", project, project, "BRANCH", "LONG", PAST, PAST));
+    assertProjectBranches(tuple("master", project, project, "LONG", PAST, PAST));
   }
 
   private void assertProjectBranches(Tuple... expectedTuples) {
-    assertThat(db.select("SELECT KEE, UUID, PROJECT_UUID, KEE_TYPE, BRANCH_TYPE, CREATED_AT, UPDATED_AT FROM PROJECT_BRANCHES")
+    assertThat(db.select("SELECT KEE, UUID, PROJECT_UUID, BRANCH_TYPE, CREATED_AT, UPDATED_AT FROM PROJECT_BRANCHES")
       .stream()
-      .map(map -> new Tuple(map.get("KEE"), map.get("UUID"), map.get("PROJECT_UUID"), map.get("KEE_TYPE"), map.get("BRANCH_TYPE"), map.get("CREATED_AT"), map.get("UPDATED_AT")))
+      .map(map -> new Tuple(map.get("KEE"), map.get("UUID"), map.get("PROJECT_UUID"), map.get("BRANCH_TYPE"), map.get("CREATED_AT"), map.get("UPDATED_AT")))
       .collect(Collectors.toList()))
         .containsExactlyInAnyOrder(expectedTuples);
   }
@@ -116,7 +116,6 @@ public class PopulateMainProjectBranchesTest {
     db.executeInsert("PROJECT_BRANCHES",
       "uuid", uuid,
       "project_uuid", uuid,
-      "kee_type", "BRANCH",
       "kee", "master",
       "branch_type", "LONG",
       "created_at", PAST,
diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v66/DropPrColumnsFromProjectBranchesTest/initial.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v66/DropPrColumnsFromProjectBranchesTest/initial.sql
deleted file mode 100644 (file)
index ceb803e..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-CREATE TABLE "PROJECT_BRANCHES" (
-  "UUID" VARCHAR(50) NOT NULL PRIMARY KEY,
-  "PROJECT_UUID" VARCHAR(50) NOT NULL,
-  "KEE_TYPE" VARCHAR(6) NOT NULL,
-  "KEE" VARCHAR(255) NOT NULL,
-  "BRANCH_TYPE" VARCHAR(5),
-  "MERGE_BRANCH_UUID" VARCHAR(50),
-  "PULL_REQUEST_TITLE" VARCHAR(4000),
-  "CREATED_AT" BIGINT NOT NULL,
-  "UPDATED_AT" BIGINT NOT NULL
-);
-CREATE UNIQUE INDEX "PK_PROJECT_BRANCHES" ON "PROJECT_BRANCHES" ("UUID");
-CREATE UNIQUE INDEX "PROJECT_BRANCHES_KEE" ON "PROJECT_BRANCHES" ("PROJECT_UUID", "KEE_TYPE", "KEE");
index 700b809073b2a3e9c9b887eadd38742b0fb1292d..7ae1777df165c4556972f31d4a79654359947845 100644 (file)
@@ -48,14 +48,11 @@ CREATE INDEX "PROJECTS_QUALIFIER" ON "PROJECTS" ("QUALIFIER");
 CREATE TABLE "PROJECT_BRANCHES" (
   "UUID" VARCHAR(50) NOT NULL PRIMARY KEY,
   "PROJECT_UUID" VARCHAR(50) NOT NULL,
-  "KEE_TYPE" VARCHAR(6) NOT NULL,
   "KEE" VARCHAR(255) NOT NULL,
   "BRANCH_TYPE" VARCHAR(5),
   "MERGE_BRANCH_UUID" VARCHAR(50),
-  "PULL_REQUEST_TITLE" VARCHAR(4000),
   "CREATED_AT" BIGINT NOT NULL,
   "UPDATED_AT" BIGINT NOT NULL
 );
 CREATE UNIQUE INDEX "PK_PROJECT_BRANCHES" ON "PROJECT_BRANCHES" ("UUID");
-CREATE UNIQUE INDEX "PROJECT_BRANCHES_KEE" ON "PROJECT_BRANCHES" ("PROJECT_UUID", "KEE_TYPE", "KEE");
-
+CREATE UNIQUE INDEX "PROJECT_BRANCHES_KEE" ON "PROJECT_BRANCHES" ("PROJECT_UUID", "KEE");