]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-13221 Set primary key of 'ISSUES' table to column 'KEE' and drop 'ID'
authorJulien Lancelot <julien.lancelot@sonarsource.com>
Fri, 3 Apr 2020 13:57:23 +0000 (15:57 +0200)
committersonartech <sonartech@sonarsource.com>
Mon, 25 May 2020 20:05:18 +0000 (20:05 +0000)
* SONAR-13221 Set primary key of 'ISSUES' table to column 'KEE' and drop 'ID'
* SONAR-13221 Move events migration in a dedicated package

36 files changed:
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/PersistIssuesStepTest.java
server/sonar-db-dao/src/main/java/org/sonar/db/issue/IssueDto.java
server/sonar-db-dao/src/main/resources/org/sonar/db/issue/IssueMapper.xml
server/sonar-db-dao/src/schema/schema-sq.ddl
server/sonar-db-dao/src/test/java/org/sonar/db/issue/IssueDaoTest.java
server/sonar-db-dao/src/test/java/org/sonar/db/issue/IssueMapperTest.java
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/AddPrimaryKeyOnUuidColumnOfEventsTable.java [deleted file]
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/DbVersion83.java
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/DropIdColumnOfEventsTable.java [deleted file]
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/DropPrimaryKeyOnIdColumnOfEventsTable.java [deleted file]
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/events/AddPrimaryKeyOnUuidColumnOfEventsTable.java [new file with mode: 0644]
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/events/DropIdColumnOfEventsTable.java [new file with mode: 0644]
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/events/DropPrimaryKeyOnIdColumnOfEventsTable.java [new file with mode: 0644]
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/issues/AddPrimaryKeyOnKeeColumnOfIssuesTable.java [new file with mode: 0644]
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/issues/DropIdColumnOfIssuesTable.java [new file with mode: 0644]
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/issues/DropPrimaryKeyOnIdColumnOfIssuesTable.java [new file with mode: 0644]
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/AddPrimaryKeyOnUuidColumnOfEventsTableTest.java [deleted file]
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/DropIdColumnOfEventsTableTest.java [deleted file]
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/DropPrimaryKeyOnIdColumnOfEventsTableTest.java [deleted file]
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/events/AddPrimaryKeyOnUuidColumnOfEventsTableTest.java [new file with mode: 0644]
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/events/DropIdColumnOfEventsTableTest.java [new file with mode: 0644]
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/events/DropPrimaryKeyOnIdColumnOfEventsTableTest.java [new file with mode: 0644]
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/issues/AddPrimaryKeyOnKeeColumnOfIssuesTableTest.java [new file with mode: 0644]
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/issues/DropIdColumnOfIssuesTableTest.java [new file with mode: 0644]
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/issues/DropPrimaryKeyOnIdColumnOfIssuesTableTest.java [new file with mode: 0644]
server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/AddPrimaryKeyOnUuidColumnOfEventsTableTest/schema.sql [deleted file]
server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/DropIdColumnOfEventsTableTest/schema.sql [deleted file]
server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/DropPrimaryKeyOnIdColumnOfEventsTableTest/schema.sql [deleted file]
server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/events/AddPrimaryKeyOnUuidColumnOfEventsTableTest/schema.sql [new file with mode: 0644]
server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/events/DropIdColumnOfEventsTableTest/schema.sql [new file with mode: 0644]
server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/events/DropPrimaryKeyOnIdColumnOfEventsTableTest/schema.sql [new file with mode: 0644]
server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/issues/AddPrimaryKeyOnKeeColumnOfIssuesTableTest/schema.sql [new file with mode: 0644]
server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/issues/DropIdColumnOfIssuesTableTest/schema.sql [new file with mode: 0644]
server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/issues/DropPrimaryKeyOnIdColumnOfIssuesTableTest/schema.sql [new file with mode: 0644]
server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/ChangelogAction.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/IssuesFinderSortTest.java

index 5941fe60b4e823c9d997645a350a78ca4ae66cd6..71fae1ae36ea51f2840b2419c61cb4242f34b5d8 100644 (file)
@@ -60,7 +60,6 @@ import static java.util.Collections.singletonList;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.data.MapEntry.entry;
 import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.anyString;
 import static org.mockito.ArgumentMatchers.eq;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.verify;
@@ -258,10 +257,9 @@ public class PersistIssuesStepTest extends BaseStepTest {
 
     ArgumentCaptor<IssueDto> issueDtoCaptor = ArgumentCaptor.forClass(IssueDto.class);
     verify(conflictResolver).resolve(eq(defaultIssue), issueDtoCaptor.capture(), any(IssueMapper.class));
-    assertThat(issueDtoCaptor.getValue().getId()).isEqualTo(issue.getId());
+    assertThat(issueDtoCaptor.getValue().getKey()).isEqualTo(issue.getKey());
     assertThat(context.getStatistics().getAll()).contains(
       entry("inserts", "0"), entry("updates", "1"), entry("merged", "1"));
-
   }
 
   @Test
index 2c151d26e79198d8a607a70ee32dc4a512baf861..6ce462903ca785e7022176392dc218e10e718069 100644 (file)
@@ -54,7 +54,6 @@ public final class IssueDto implements Serializable {
   private static final Joiner TAGS_JOINER = Joiner.on(TAGS_SEPARATOR).skipNulls();
   private static final Splitter TAGS_SPLITTER = Splitter.on(',').trimResults().omitEmptyStrings();
 
-  private Long id;
   private int type;
   private String kee;
   private String componentUuid;
@@ -190,15 +189,6 @@ public final class IssueDto implements Serializable {
     return getKee();
   }
 
-  public Long getId() {
-    return id;
-  }
-
-  public IssueDto setId(@Nullable Long id) {
-    this.id = id;
-    return this;
-  }
-
   public String getKee() {
     return kee;
   }
index cf6c1b87322d70bff40c970a3c9cd31c8e63ad9b..ad92cab0658c405c5944f154755e41e675b3909e 100644 (file)
@@ -5,7 +5,6 @@
 <mapper namespace="org.sonar.db.issue.IssueMapper">
 
   <sql id="issueColumns">
-    i.id,
     i.kee as kee,
     i.rule_id as ruleId,
     i.severity as severity,
@@ -99,7 +98,7 @@
   </sql>
 
 
-  <insert id="insert" parameterType="Issue" useGeneratedKeys="false" keyProperty="id">
+  <insert id="insert" parameterType="Issue" useGeneratedKeys="false">
     INSERT INTO issues (kee, rule_id, severity, manual_severity,
     message, line, locations, gap, effort, status, tags,
     resolution, checksum, assignee, author_login, issue_attributes, issue_creation_date, issue_update_date,
index 0af1d35bc97007a8c43e23e715ff73d3a026b965..74be76f621fbafbb901df9c5c5a8cf3fae3744d9 100644 (file)
@@ -379,7 +379,6 @@ CREATE INDEX "ISSUE_CHANGES_ISSUE_KEY" ON "ISSUE_CHANGES"("ISSUE_KEY");
 CREATE INDEX "ISSUE_CHANGES_KEE" ON "ISSUE_CHANGES"("KEE");
 
 CREATE TABLE "ISSUES"(
-    "ID" BIGINT NOT NULL AUTO_INCREMENT (1,1),
     "KEE" VARCHAR(50) NOT NULL,
     "RULE_ID" INTEGER,
     "SEVERITY" VARCHAR(10),
@@ -408,7 +407,7 @@ CREATE TABLE "ISSUES"(
     "ISSUE_TYPE" TINYINT,
     "FROM_HOTSPOT" BOOLEAN
 );
-ALTER TABLE "ISSUES" ADD CONSTRAINT "PK_ISSUES" PRIMARY KEY("ID");
+ALTER TABLE "ISSUES" ADD CONSTRAINT "PK_ISSUES" PRIMARY KEY("KEE");
 CREATE INDEX "ISSUES_ASSIGNEE" ON "ISSUES"("ASSIGNEE");
 CREATE INDEX "ISSUES_COMPONENT_UUID" ON "ISSUES"("COMPONENT_UUID");
 CREATE INDEX "ISSUES_CREATION_DATE" ON "ISSUES"("ISSUE_CREATION_DATE");
index 0e5e3280444c0b6fb5a9a40eca5fc8cefe5151f7..daeba88d07e19414e75b740caa24f9aca0cc890d 100644 (file)
@@ -79,7 +79,6 @@ public class IssueDaoTest {
 
     IssueDto issue = underTest.selectOrFailByKey(db.getSession(), ISSUE_KEY1);
     assertThat(issue.getKee()).isEqualTo(ISSUE_KEY1);
-    assertThat(issue.getId()).isGreaterThan(0L);
     assertThat(issue.getComponentUuid()).isEqualTo(FILE_UUID);
     assertThat(issue.getProjectUuid()).isEqualTo(PROJECT_UUID);
     assertThat(issue.getRuleId()).isEqualTo(RULE.getId());
index 8e7b4ab7b4c17e77b69e8e10a7db4e45f462845c..cecef80eecafb06f7d31c47cac64d9b86fa26e19 100644 (file)
@@ -93,7 +93,6 @@ public class IssueMapperTest {
 
     IssueDto result = underTest.selectByKey("ABCDE");
     assertThat(result).isNotNull();
-    assertThat(result.getId()).isNotNull();
     assertThat(result.getKey()).isEqualTo("ABCDE");
     assertThat(result.getComponentUuid()).isEqualTo(file.uuid());
     assertThat(result.getProjectUuid()).isEqualTo(project.uuid());
@@ -153,7 +152,6 @@ public class IssueMapperTest {
 
     IssueDto result = underTest.selectByKey("ABCDE");
     assertThat(result).isNotNull();
-    assertThat(result.getId()).isNotNull();
     assertThat(result.getKey()).isEqualTo("ABCDE");
     assertThat(result.getComponentUuid()).isEqualTo(file.uuid());
     assertThat(result.getProjectUuid()).isEqualTo(project.uuid());
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/AddPrimaryKeyOnUuidColumnOfEventsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/AddPrimaryKeyOnUuidColumnOfEventsTable.java
deleted file mode 100644 (file)
index a615d0d..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2020 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.v83;
-
-import java.sql.SQLException;
-import org.sonar.db.Database;
-import org.sonar.server.platform.db.migration.step.DdlChange;
-import org.sonar.server.platform.db.migration.version.v83.util.AddPrimaryKeyBuilder;
-
-public class AddPrimaryKeyOnUuidColumnOfEventsTable extends DdlChange {
-
-  public AddPrimaryKeyOnUuidColumnOfEventsTable(Database db) {
-    super(db);
-  }
-
-  @Override
-  public void execute(Context context) throws SQLException {
-    context.execute(new AddPrimaryKeyBuilder("events", "uuid").build());
-  }
-
-}
index b5758075011650dfbd82bdb5ec5f70815b779239..bf8d2d0a5931891e331f1ffd4c7504181979a4d4 100644 (file)
@@ -21,6 +21,12 @@ package org.sonar.server.platform.db.migration.version.v83;
 
 import org.sonar.server.platform.db.migration.step.MigrationStepRegistry;
 import org.sonar.server.platform.db.migration.version.DbVersion;
+import org.sonar.server.platform.db.migration.version.v83.events.AddPrimaryKeyOnUuidColumnOfEventsTable;
+import org.sonar.server.platform.db.migration.version.v83.events.DropIdColumnOfEventsTable;
+import org.sonar.server.platform.db.migration.version.v83.events.DropPrimaryKeyOnIdColumnOfEventsTable;
+import org.sonar.server.platform.db.migration.version.v83.issues.AddPrimaryKeyOnKeeColumnOfIssuesTable;
+import org.sonar.server.platform.db.migration.version.v83.issues.DropIdColumnOfIssuesTable;
+import org.sonar.server.platform.db.migration.version.v83.issues.DropPrimaryKeyOnIdColumnOfIssuesTable;
 import org.sonar.server.platform.db.migration.version.v83.notifications.AddPrimaryKeyOnUuidColumnOfNotificationTable;
 import org.sonar.server.platform.db.migration.version.v83.notifications.AddUuidAndCreatedAtColumnsToNotification;
 import org.sonar.server.platform.db.migration.version.v83.notifications.DropIdColumnOfNotificationTable;
@@ -58,6 +64,11 @@ public class DbVersion83 implements DbVersion {
       .add(3407, "Add primary key on 'UUID' column of 'NOTIFICATIONS' table", AddPrimaryKeyOnUuidColumnOfNotificationTable.class)
       .add(3408, "Drop column 'ID' of 'NOTIFICATIONS' table", DropIdColumnOfNotificationTable.class)
 
+      // Migration on ISSUES table
+      .add(3409, "Drop primary key on 'ID' column of 'ISSUES' table", DropPrimaryKeyOnIdColumnOfIssuesTable.class)
+      .add(3410, "Add primary key on 'KEE' column of 'ISSUES' table", AddPrimaryKeyOnKeeColumnOfIssuesTable.class)
+      .add(3411, "Drop column 'ID' of 'ISSUES' table", DropIdColumnOfIssuesTable.class)
+
     ;
   }
 }
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/DropIdColumnOfEventsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/DropIdColumnOfEventsTable.java
deleted file mode 100644 (file)
index 0755264..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2020 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.v83;
-
-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 DropIdColumnOfEventsTable extends DdlChange {
-
-  private Database db;
-
-  public DropIdColumnOfEventsTable(Database db) {
-    super(db);
-    this.db = db;
-  }
-
-  @Override
-  public void execute(Context context) throws SQLException {
-    context.execute(new DropColumnsBuilder(db.getDialect(), "events", "id").build());
-  }
-
-}
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/DropPrimaryKeyOnIdColumnOfEventsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/DropPrimaryKeyOnIdColumnOfEventsTable.java
deleted file mode 100644 (file)
index a5ca4b0..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2020 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.v83;
-
-import java.sql.SQLException;
-import org.sonar.db.Database;
-import org.sonar.server.platform.db.migration.step.DdlChange;
-import org.sonar.server.platform.db.migration.version.v83.util.DropPrimaryKeySqlGenerator;
-
-public class DropPrimaryKeyOnIdColumnOfEventsTable extends DdlChange {
-
-  private final DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator;
-
-  public DropPrimaryKeyOnIdColumnOfEventsTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) {
-    super(db);
-    this.dropPrimaryKeySqlGenerator = dropPrimaryKeySqlGenerator;
-  }
-
-  @Override
-  public void execute(Context context) throws SQLException {
-    context.execute(dropPrimaryKeySqlGenerator.generate("events", "events", "id"));
-  }
-
-}
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/events/AddPrimaryKeyOnUuidColumnOfEventsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/events/AddPrimaryKeyOnUuidColumnOfEventsTable.java
new file mode 100644 (file)
index 0000000..cbf84c5
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2020 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.v83.events;
+
+import java.sql.SQLException;
+import org.sonar.db.Database;
+import org.sonar.server.platform.db.migration.step.DdlChange;
+import org.sonar.server.platform.db.migration.version.v83.util.AddPrimaryKeyBuilder;
+
+public class AddPrimaryKeyOnUuidColumnOfEventsTable extends DdlChange {
+
+  public AddPrimaryKeyOnUuidColumnOfEventsTable(Database db) {
+    super(db);
+  }
+
+  @Override
+  public void execute(Context context) throws SQLException {
+    context.execute(new AddPrimaryKeyBuilder("events", "uuid").build());
+  }
+
+}
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/events/DropIdColumnOfEventsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/events/DropIdColumnOfEventsTable.java
new file mode 100644 (file)
index 0000000..fddda4a
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2020 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.v83.events;
+
+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 DropIdColumnOfEventsTable extends DdlChange {
+
+  private Database db;
+
+  public DropIdColumnOfEventsTable(Database db) {
+    super(db);
+    this.db = db;
+  }
+
+  @Override
+  public void execute(Context context) throws SQLException {
+    context.execute(new DropColumnsBuilder(db.getDialect(), "events", "id").build());
+  }
+
+}
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/events/DropPrimaryKeyOnIdColumnOfEventsTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/events/DropPrimaryKeyOnIdColumnOfEventsTable.java
new file mode 100644 (file)
index 0000000..9e42288
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2020 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.v83.events;
+
+import java.sql.SQLException;
+import org.sonar.db.Database;
+import org.sonar.server.platform.db.migration.step.DdlChange;
+import org.sonar.server.platform.db.migration.version.v83.util.DropPrimaryKeySqlGenerator;
+
+public class DropPrimaryKeyOnIdColumnOfEventsTable extends DdlChange {
+
+  private final DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator;
+
+  public DropPrimaryKeyOnIdColumnOfEventsTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) {
+    super(db);
+    this.dropPrimaryKeySqlGenerator = dropPrimaryKeySqlGenerator;
+  }
+
+  @Override
+  public void execute(Context context) throws SQLException {
+    context.execute(dropPrimaryKeySqlGenerator.generate("events", "events", "id"));
+  }
+
+}
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/issues/AddPrimaryKeyOnKeeColumnOfIssuesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/issues/AddPrimaryKeyOnKeeColumnOfIssuesTable.java
new file mode 100644 (file)
index 0000000..84e03c5
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2020 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.v83.issues;
+
+import java.sql.SQLException;
+import org.sonar.db.Database;
+import org.sonar.server.platform.db.migration.step.DdlChange;
+import org.sonar.server.platform.db.migration.version.v83.util.AddPrimaryKeyBuilder;
+
+public class AddPrimaryKeyOnKeeColumnOfIssuesTable extends DdlChange {
+
+  public AddPrimaryKeyOnKeeColumnOfIssuesTable(Database db) {
+    super(db);
+  }
+
+  @Override
+  public void execute(Context context) throws SQLException {
+    context.execute(new AddPrimaryKeyBuilder("issues", "kee").build());
+  }
+
+}
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/issues/DropIdColumnOfIssuesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/issues/DropIdColumnOfIssuesTable.java
new file mode 100644 (file)
index 0000000..462504e
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2020 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.v83.issues;
+
+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 DropIdColumnOfIssuesTable extends DdlChange {
+
+  private Database db;
+
+  public DropIdColumnOfIssuesTable(Database db) {
+    super(db);
+    this.db = db;
+  }
+
+  @Override
+  public void execute(Context context) throws SQLException {
+    context.execute(new DropColumnsBuilder(db.getDialect(), "issues", "id").build());
+  }
+
+}
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/issues/DropPrimaryKeyOnIdColumnOfIssuesTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v83/issues/DropPrimaryKeyOnIdColumnOfIssuesTable.java
new file mode 100644 (file)
index 0000000..bfef73c
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2020 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.v83.issues;
+
+import java.sql.SQLException;
+import org.sonar.db.Database;
+import org.sonar.server.platform.db.migration.step.DdlChange;
+import org.sonar.server.platform.db.migration.version.v83.util.DropPrimaryKeySqlGenerator;
+
+public class DropPrimaryKeyOnIdColumnOfIssuesTable extends DdlChange {
+
+  private final DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator;
+
+  public DropPrimaryKeyOnIdColumnOfIssuesTable(Database db, DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator) {
+    super(db);
+    this.dropPrimaryKeySqlGenerator = dropPrimaryKeySqlGenerator;
+  }
+
+  @Override
+  public void execute(Context context) throws SQLException {
+    context.execute(dropPrimaryKeySqlGenerator.generate("issues", "issues","id"));
+  }
+
+}
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/AddPrimaryKeyOnUuidColumnOfEventsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/AddPrimaryKeyOnUuidColumnOfEventsTableTest.java
deleted file mode 100644 (file)
index d8eb67b..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2020 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.v83;
-
-import java.sql.SQLException;
-import org.junit.Rule;
-import org.junit.Test;
-import org.sonar.db.CoreDbTester;
-
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-
-public class AddPrimaryKeyOnUuidColumnOfEventsTableTest {
-
-  @Rule
-  public CoreDbTester db = CoreDbTester.createForSchema(AddPrimaryKeyOnUuidColumnOfEventsTableTest.class, "schema.sql");
-
-  private AddPrimaryKeyOnUuidColumnOfEventsTable underTest = new AddPrimaryKeyOnUuidColumnOfEventsTable(db.database());
-
-  @Test
-  public void execute() throws SQLException {
-    underTest.execute();
-
-    db.assertPrimaryKey("events", "pk_events", "uuid");
-  }
-
-  @Test
-  public void migration_is_not_re_entrant() throws SQLException {
-    underTest.execute();
-
-    assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class);
-  }
-}
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/DropIdColumnOfEventsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/DropIdColumnOfEventsTableTest.java
deleted file mode 100644 (file)
index e82c457..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2020 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.v83;
-
-import java.sql.SQLException;
-import org.junit.Rule;
-import org.junit.Test;
-import org.sonar.db.CoreDbTester;
-
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-
-public class DropIdColumnOfEventsTableTest {
-
-  @Rule
-  public CoreDbTester db = CoreDbTester.createForSchema(DropIdColumnOfEventsTableTest.class, "schema.sql");
-
-  private DropIdColumnOfEventsTable underTest = new DropIdColumnOfEventsTable(db.database());
-
-  @Test
-  public void execute() throws SQLException {
-    underTest.execute();
-
-    db.assertColumnDoesNotExist("events", "id");
-  }
-
-  @Test
-  public void migration_is_not_re_entrant() throws SQLException {
-    underTest.execute();
-
-    assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class);
-  }
-
-}
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/DropPrimaryKeyOnIdColumnOfEventsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/DropPrimaryKeyOnIdColumnOfEventsTableTest.java
deleted file mode 100644 (file)
index 17e262b..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2020 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.v83;
-
-import java.sql.SQLException;
-import org.junit.Rule;
-import org.junit.Test;
-import org.sonar.db.CoreDbTester;
-import org.sonar.server.platform.db.migration.version.v83.util.DropPrimaryKeySqlGenerator;
-import org.sonar.server.platform.db.migration.version.v83.util.GetConstraintHelper;
-
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-
-public class DropPrimaryKeyOnIdColumnOfEventsTableTest {
-
-  private static final String TABLE_NAME = "events";
-  @Rule
-  public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfEventsTableTest.class, "schema.sql");
-
-  private DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new GetConstraintHelper(db.database()));
-
-  private DropPrimaryKeyOnIdColumnOfEventsTable underTest = new DropPrimaryKeyOnIdColumnOfEventsTable(db.database(), dropPrimaryKeySqlGenerator);
-
-  @Test
-  public void execute() throws SQLException {
-    underTest.execute();
-
-    db.assertNoPrimaryKey(TABLE_NAME);
-  }
-
-  @Test
-  public void migration_is_not_re_entrant() throws SQLException {
-    underTest.execute();
-
-    assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class);
-  }
-}
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/events/AddPrimaryKeyOnUuidColumnOfEventsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/events/AddPrimaryKeyOnUuidColumnOfEventsTableTest.java
new file mode 100644 (file)
index 0000000..a7d546f
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2020 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.v83.events;
+
+import java.sql.SQLException;
+import org.junit.Rule;
+import org.junit.Test;
+import org.sonar.db.CoreDbTester;
+
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+public class AddPrimaryKeyOnUuidColumnOfEventsTableTest {
+
+  @Rule
+  public CoreDbTester db = CoreDbTester.createForSchema(AddPrimaryKeyOnUuidColumnOfEventsTableTest.class, "schema.sql");
+
+  private AddPrimaryKeyOnUuidColumnOfEventsTable underTest = new AddPrimaryKeyOnUuidColumnOfEventsTable(db.database());
+
+  @Test
+  public void execute() throws SQLException {
+    underTest.execute();
+
+    db.assertPrimaryKey("events", "pk_events", "uuid");
+  }
+
+  @Test
+  public void migration_is_not_re_entrant() throws SQLException {
+    underTest.execute();
+
+    assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class);
+  }
+}
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/events/DropIdColumnOfEventsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/events/DropIdColumnOfEventsTableTest.java
new file mode 100644 (file)
index 0000000..220f09c
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2020 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.v83.events;
+
+import java.sql.SQLException;
+import org.junit.Rule;
+import org.junit.Test;
+import org.sonar.db.CoreDbTester;
+
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+public class DropIdColumnOfEventsTableTest {
+
+  @Rule
+  public CoreDbTester db = CoreDbTester.createForSchema(DropIdColumnOfEventsTableTest.class, "schema.sql");
+
+  private DropIdColumnOfEventsTable underTest = new DropIdColumnOfEventsTable(db.database());
+
+  @Test
+  public void execute() throws SQLException {
+    underTest.execute();
+
+    db.assertColumnDoesNotExist("events", "id");
+  }
+
+  @Test
+  public void migration_is_not_re_entrant() throws SQLException {
+    underTest.execute();
+
+    assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class);
+  }
+
+}
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/events/DropPrimaryKeyOnIdColumnOfEventsTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/events/DropPrimaryKeyOnIdColumnOfEventsTableTest.java
new file mode 100644 (file)
index 0000000..d970010
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2020 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.v83.events;
+
+import java.sql.SQLException;
+import org.junit.Rule;
+import org.junit.Test;
+import org.sonar.db.CoreDbTester;
+import org.sonar.server.platform.db.migration.version.v83.util.DropPrimaryKeySqlGenerator;
+import org.sonar.server.platform.db.migration.version.v83.util.GetConstraintHelper;
+
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+public class DropPrimaryKeyOnIdColumnOfEventsTableTest {
+
+  private static final String TABLE_NAME = "events";
+  @Rule
+  public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfEventsTableTest.class, "schema.sql");
+
+  private DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new GetConstraintHelper(db.database()));
+
+  private DropPrimaryKeyOnIdColumnOfEventsTable underTest = new DropPrimaryKeyOnIdColumnOfEventsTable(db.database(), dropPrimaryKeySqlGenerator);
+
+  @Test
+  public void execute() throws SQLException {
+    underTest.execute();
+
+    db.assertNoPrimaryKey(TABLE_NAME);
+  }
+
+  @Test
+  public void migration_is_not_re_entrant() throws SQLException {
+    underTest.execute();
+
+    assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class);
+  }
+}
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/issues/AddPrimaryKeyOnKeeColumnOfIssuesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/issues/AddPrimaryKeyOnKeeColumnOfIssuesTableTest.java
new file mode 100644 (file)
index 0000000..64a7512
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2020 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.v83.issues;
+
+import java.sql.SQLException;
+import org.junit.Rule;
+import org.junit.Test;
+import org.sonar.db.CoreDbTester;
+
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+public class AddPrimaryKeyOnKeeColumnOfIssuesTableTest {
+
+  @Rule
+  public CoreDbTester db = CoreDbTester.createForSchema(AddPrimaryKeyOnKeeColumnOfIssuesTableTest.class, "schema.sql");
+
+  private AddPrimaryKeyOnKeeColumnOfIssuesTable underTest = new AddPrimaryKeyOnKeeColumnOfIssuesTable(db.database());
+
+  @Test
+  public void execute() throws SQLException {
+    underTest.execute();
+
+    db.assertPrimaryKey("issues", "pk_issues", "kee");
+  }
+
+  @Test
+  public void migration_is_not_re_entrant() throws SQLException {
+    underTest.execute();
+
+    assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class);
+  }
+}
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/issues/DropIdColumnOfIssuesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/issues/DropIdColumnOfIssuesTableTest.java
new file mode 100644 (file)
index 0000000..877e66f
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2020 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.v83.issues;
+
+import java.sql.SQLException;
+import org.junit.Rule;
+import org.junit.Test;
+import org.sonar.db.CoreDbTester;
+
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+public class DropIdColumnOfIssuesTableTest {
+
+  @Rule
+  public CoreDbTester db = CoreDbTester.createForSchema(DropIdColumnOfIssuesTableTest.class, "schema.sql");
+
+  private DropIdColumnOfIssuesTable underTest = new DropIdColumnOfIssuesTable(db.database());
+
+  @Test
+  public void execute() throws SQLException {
+    underTest.execute();
+
+    db.assertColumnDoesNotExist("issues", "id");
+  }
+
+  @Test
+  public void migration_is_not_re_entrant() throws SQLException {
+    underTest.execute();
+
+    assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class);
+  }
+
+}
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/issues/DropPrimaryKeyOnIdColumnOfIssuesTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/issues/DropPrimaryKeyOnIdColumnOfIssuesTableTest.java
new file mode 100644 (file)
index 0000000..7acfaae
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2020 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.v83.issues;
+
+import java.sql.SQLException;
+import org.junit.Rule;
+import org.junit.Test;
+import org.sonar.db.CoreDbTester;
+import org.sonar.server.platform.db.migration.version.v83.util.DropPrimaryKeySqlGenerator;
+import org.sonar.server.platform.db.migration.version.v83.util.GetConstraintHelper;
+
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+public class DropPrimaryKeyOnIdColumnOfIssuesTableTest {
+
+  private static final String TABLE_NAME = "issues";
+  @Rule
+  public CoreDbTester db = CoreDbTester.createForSchema(DropPrimaryKeyOnIdColumnOfIssuesTableTest.class, "schema.sql");
+
+  private DropPrimaryKeySqlGenerator dropPrimaryKeySqlGenerator = new DropPrimaryKeySqlGenerator(db.database(), new GetConstraintHelper(db.database()));
+
+  private DropPrimaryKeyOnIdColumnOfIssuesTable underTest = new DropPrimaryKeyOnIdColumnOfIssuesTable(db.database(), dropPrimaryKeySqlGenerator);
+
+  @Test
+  public void execute() throws SQLException {
+    underTest.execute();
+
+    db.assertNoPrimaryKey(TABLE_NAME);
+  }
+
+  @Test
+  public void migration_is_not_re_entrant() throws SQLException {
+    underTest.execute();
+
+    assertThatThrownBy(() -> underTest.execute()).isInstanceOf(IllegalStateException.class);
+  }
+}
diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/AddPrimaryKeyOnUuidColumnOfEventsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/AddPrimaryKeyOnUuidColumnOfEventsTableTest/schema.sql
deleted file mode 100644 (file)
index bd6b897..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-CREATE TABLE "EVENTS"(
-    "ID" INTEGER NOT NULL,
-    "UUID" VARCHAR(40) NOT NULL,
-    "ANALYSIS_UUID" VARCHAR(50) NOT NULL,
-    "NAME" VARCHAR(400),
-    "CATEGORY" VARCHAR(50),
-    "DESCRIPTION" VARCHAR(4000),
-    "EVENT_DATA" VARCHAR(4000),
-    "EVENT_DATE" BIGINT NOT NULL,
-    "CREATED_AT" BIGINT NOT NULL,
-    "COMPONENT_UUID" VARCHAR(50) NOT NULL
-);
-CREATE UNIQUE INDEX "EVENTS_UUID" ON "EVENTS"("UUID");
-CREATE INDEX "EVENTS_ANALYSIS" ON "EVENTS"("ANALYSIS_UUID");
-CREATE INDEX "EVENTS_COMPONENT_UUID" ON "EVENTS"("COMPONENT_UUID");
diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/DropIdColumnOfEventsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/DropIdColumnOfEventsTableTest/schema.sql
deleted file mode 100644 (file)
index ac79cfa..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-CREATE TABLE "EVENTS"(
-    "ID" INTEGER NOT NULL,
-    "UUID" VARCHAR(40) NOT NULL,
-    "ANALYSIS_UUID" VARCHAR(50) NOT NULL,
-    "NAME" VARCHAR(400),
-    "CATEGORY" VARCHAR(50),
-    "DESCRIPTION" VARCHAR(4000),
-    "EVENT_DATA" VARCHAR(4000),
-    "EVENT_DATE" BIGINT NOT NULL,
-    "CREATED_AT" BIGINT NOT NULL,
-    "COMPONENT_UUID" VARCHAR(50) NOT NULL
-);
-ALTER TABLE "EVENTS" ADD CONSTRAINT "PK_EVENTS" PRIMARY KEY("UUID");
-CREATE UNIQUE INDEX "EVENTS_UUID" ON "EVENTS"("UUID");
-CREATE INDEX "EVENTS_ANALYSIS" ON "EVENTS"("ANALYSIS_UUID");
-CREATE INDEX "EVENTS_COMPONENT_UUID" ON "EVENTS"("COMPONENT_UUID");
diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/DropPrimaryKeyOnIdColumnOfEventsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/DropPrimaryKeyOnIdColumnOfEventsTableTest/schema.sql
deleted file mode 100644 (file)
index 2f03d9d..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-CREATE TABLE "EVENTS"(
-    "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1),
-    "UUID" VARCHAR(40) NOT NULL,
-    "ANALYSIS_UUID" VARCHAR(50) NOT NULL,
-    "NAME" VARCHAR(400),
-    "CATEGORY" VARCHAR(50),
-    "DESCRIPTION" VARCHAR(4000),
-    "EVENT_DATA" VARCHAR(4000),
-    "EVENT_DATE" BIGINT NOT NULL,
-    "CREATED_AT" BIGINT NOT NULL,
-    "COMPONENT_UUID" VARCHAR(50) NOT NULL
-);
-ALTER TABLE "EVENTS" ADD CONSTRAINT "PK_EVENTS" PRIMARY KEY("ID");
-CREATE UNIQUE INDEX "EVENTS_UUID" ON "EVENTS"("UUID");
-CREATE INDEX "EVENTS_ANALYSIS" ON "EVENTS"("ANALYSIS_UUID");
-CREATE INDEX "EVENTS_COMPONENT_UUID" ON "EVENTS"("COMPONENT_UUID");
diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/events/AddPrimaryKeyOnUuidColumnOfEventsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/events/AddPrimaryKeyOnUuidColumnOfEventsTableTest/schema.sql
new file mode 100644 (file)
index 0000000..bd6b897
--- /dev/null
@@ -0,0 +1,15 @@
+CREATE TABLE "EVENTS"(
+    "ID" INTEGER NOT NULL,
+    "UUID" VARCHAR(40) NOT NULL,
+    "ANALYSIS_UUID" VARCHAR(50) NOT NULL,
+    "NAME" VARCHAR(400),
+    "CATEGORY" VARCHAR(50),
+    "DESCRIPTION" VARCHAR(4000),
+    "EVENT_DATA" VARCHAR(4000),
+    "EVENT_DATE" BIGINT NOT NULL,
+    "CREATED_AT" BIGINT NOT NULL,
+    "COMPONENT_UUID" VARCHAR(50) NOT NULL
+);
+CREATE UNIQUE INDEX "EVENTS_UUID" ON "EVENTS"("UUID");
+CREATE INDEX "EVENTS_ANALYSIS" ON "EVENTS"("ANALYSIS_UUID");
+CREATE INDEX "EVENTS_COMPONENT_UUID" ON "EVENTS"("COMPONENT_UUID");
diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/events/DropIdColumnOfEventsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/events/DropIdColumnOfEventsTableTest/schema.sql
new file mode 100644 (file)
index 0000000..ac79cfa
--- /dev/null
@@ -0,0 +1,16 @@
+CREATE TABLE "EVENTS"(
+    "ID" INTEGER NOT NULL,
+    "UUID" VARCHAR(40) NOT NULL,
+    "ANALYSIS_UUID" VARCHAR(50) NOT NULL,
+    "NAME" VARCHAR(400),
+    "CATEGORY" VARCHAR(50),
+    "DESCRIPTION" VARCHAR(4000),
+    "EVENT_DATA" VARCHAR(4000),
+    "EVENT_DATE" BIGINT NOT NULL,
+    "CREATED_AT" BIGINT NOT NULL,
+    "COMPONENT_UUID" VARCHAR(50) NOT NULL
+);
+ALTER TABLE "EVENTS" ADD CONSTRAINT "PK_EVENTS" PRIMARY KEY("UUID");
+CREATE UNIQUE INDEX "EVENTS_UUID" ON "EVENTS"("UUID");
+CREATE INDEX "EVENTS_ANALYSIS" ON "EVENTS"("ANALYSIS_UUID");
+CREATE INDEX "EVENTS_COMPONENT_UUID" ON "EVENTS"("COMPONENT_UUID");
diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/events/DropPrimaryKeyOnIdColumnOfEventsTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/events/DropPrimaryKeyOnIdColumnOfEventsTableTest/schema.sql
new file mode 100644 (file)
index 0000000..2f03d9d
--- /dev/null
@@ -0,0 +1,16 @@
+CREATE TABLE "EVENTS"(
+    "ID" INTEGER NOT NULL AUTO_INCREMENT (1,1),
+    "UUID" VARCHAR(40) NOT NULL,
+    "ANALYSIS_UUID" VARCHAR(50) NOT NULL,
+    "NAME" VARCHAR(400),
+    "CATEGORY" VARCHAR(50),
+    "DESCRIPTION" VARCHAR(4000),
+    "EVENT_DATA" VARCHAR(4000),
+    "EVENT_DATE" BIGINT NOT NULL,
+    "CREATED_AT" BIGINT NOT NULL,
+    "COMPONENT_UUID" VARCHAR(50) NOT NULL
+);
+ALTER TABLE "EVENTS" ADD CONSTRAINT "PK_EVENTS" PRIMARY KEY("ID");
+CREATE UNIQUE INDEX "EVENTS_UUID" ON "EVENTS"("UUID");
+CREATE INDEX "EVENTS_ANALYSIS" ON "EVENTS"("ANALYSIS_UUID");
+CREATE INDEX "EVENTS_COMPONENT_UUID" ON "EVENTS"("COMPONENT_UUID");
diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/issues/AddPrimaryKeyOnKeeColumnOfIssuesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/issues/AddPrimaryKeyOnKeeColumnOfIssuesTableTest/schema.sql
new file mode 100644 (file)
index 0000000..c195339
--- /dev/null
@@ -0,0 +1,38 @@
+CREATE TABLE "ISSUES"(
+    "ID" BIGINT NOT NULL,
+    "KEE" VARCHAR(50) NOT NULL,
+    "RULE_ID" INTEGER,
+    "SEVERITY" VARCHAR(10),
+    "MANUAL_SEVERITY" BOOLEAN NOT NULL,
+    "MESSAGE" VARCHAR(4000),
+    "LINE" INTEGER,
+    "GAP" DOUBLE,
+    "STATUS" VARCHAR(20),
+    "RESOLUTION" VARCHAR(20),
+    "CHECKSUM" VARCHAR(1000),
+    "REPORTER" VARCHAR(255),
+    "ASSIGNEE" VARCHAR(255),
+    "AUTHOR_LOGIN" VARCHAR(255),
+    "ACTION_PLAN_KEY" VARCHAR(50),
+    "ISSUE_ATTRIBUTES" VARCHAR(4000),
+    "EFFORT" INTEGER,
+    "CREATED_AT" BIGINT,
+    "UPDATED_AT" BIGINT,
+    "ISSUE_CREATION_DATE" BIGINT,
+    "ISSUE_UPDATE_DATE" BIGINT,
+    "ISSUE_CLOSE_DATE" BIGINT,
+    "TAGS" VARCHAR(4000),
+    "COMPONENT_UUID" VARCHAR(50),
+    "PROJECT_UUID" VARCHAR(50),
+    "LOCATIONS" BLOB,
+    "ISSUE_TYPE" TINYINT,
+    "FROM_HOTSPOT" BOOLEAN
+);
+CREATE INDEX "ISSUES_ASSIGNEE" ON "ISSUES"("ASSIGNEE");
+CREATE INDEX "ISSUES_COMPONENT_UUID" ON "ISSUES"("COMPONENT_UUID");
+CREATE INDEX "ISSUES_CREATION_DATE" ON "ISSUES"("ISSUE_CREATION_DATE");
+CREATE UNIQUE INDEX "ISSUES_KEE" ON "ISSUES"("KEE");
+CREATE INDEX "ISSUES_PROJECT_UUID" ON "ISSUES"("PROJECT_UUID");
+CREATE INDEX "ISSUES_RESOLUTION" ON "ISSUES"("RESOLUTION");
+CREATE INDEX "ISSUES_RULE_ID" ON "ISSUES"("RULE_ID");
+CREATE INDEX "ISSUES_UPDATED_AT" ON "ISSUES"("UPDATED_AT");
diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/issues/DropIdColumnOfIssuesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/issues/DropIdColumnOfIssuesTableTest/schema.sql
new file mode 100644 (file)
index 0000000..92fadc6
--- /dev/null
@@ -0,0 +1,39 @@
+CREATE TABLE "ISSUES"(
+    "ID" BIGINT NOT NULL,
+    "KEE" VARCHAR(50) NOT NULL,
+    "RULE_ID" INTEGER,
+    "SEVERITY" VARCHAR(10),
+    "MANUAL_SEVERITY" BOOLEAN NOT NULL,
+    "MESSAGE" VARCHAR(4000),
+    "LINE" INTEGER,
+    "GAP" DOUBLE,
+    "STATUS" VARCHAR(20),
+    "RESOLUTION" VARCHAR(20),
+    "CHECKSUM" VARCHAR(1000),
+    "REPORTER" VARCHAR(255),
+    "ASSIGNEE" VARCHAR(255),
+    "AUTHOR_LOGIN" VARCHAR(255),
+    "ACTION_PLAN_KEY" VARCHAR(50),
+    "ISSUE_ATTRIBUTES" VARCHAR(4000),
+    "EFFORT" INTEGER,
+    "CREATED_AT" BIGINT,
+    "UPDATED_AT" BIGINT,
+    "ISSUE_CREATION_DATE" BIGINT,
+    "ISSUE_UPDATE_DATE" BIGINT,
+    "ISSUE_CLOSE_DATE" BIGINT,
+    "TAGS" VARCHAR(4000),
+    "COMPONENT_UUID" VARCHAR(50),
+    "PROJECT_UUID" VARCHAR(50),
+    "LOCATIONS" BLOB,
+    "ISSUE_TYPE" TINYINT,
+    "FROM_HOTSPOT" BOOLEAN
+);
+ALTER TABLE "ISSUES" ADD CONSTRAINT "PK_ISSUES" PRIMARY KEY("KEE");
+CREATE INDEX "ISSUES_ASSIGNEE" ON "ISSUES"("ASSIGNEE");
+CREATE INDEX "ISSUES_COMPONENT_UUID" ON "ISSUES"("COMPONENT_UUID");
+CREATE INDEX "ISSUES_CREATION_DATE" ON "ISSUES"("ISSUE_CREATION_DATE");
+CREATE UNIQUE INDEX "ISSUES_KEE" ON "ISSUES"("KEE");
+CREATE INDEX "ISSUES_PROJECT_UUID" ON "ISSUES"("PROJECT_UUID");
+CREATE INDEX "ISSUES_RESOLUTION" ON "ISSUES"("RESOLUTION");
+CREATE INDEX "ISSUES_RULE_ID" ON "ISSUES"("RULE_ID");
+CREATE INDEX "ISSUES_UPDATED_AT" ON "ISSUES"("UPDATED_AT");
diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/issues/DropPrimaryKeyOnIdColumnOfIssuesTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v83/issues/DropPrimaryKeyOnIdColumnOfIssuesTableTest/schema.sql
new file mode 100644 (file)
index 0000000..cf65bc4
--- /dev/null
@@ -0,0 +1,39 @@
+CREATE TABLE "ISSUES"(
+    "ID" BIGINT NOT NULL AUTO_INCREMENT (1,1),
+    "KEE" VARCHAR(50) NOT NULL,
+    "RULE_ID" INTEGER,
+    "SEVERITY" VARCHAR(10),
+    "MANUAL_SEVERITY" BOOLEAN NOT NULL,
+    "MESSAGE" VARCHAR(4000),
+    "LINE" INTEGER,
+    "GAP" DOUBLE,
+    "STATUS" VARCHAR(20),
+    "RESOLUTION" VARCHAR(20),
+    "CHECKSUM" VARCHAR(1000),
+    "REPORTER" VARCHAR(255),
+    "ASSIGNEE" VARCHAR(255),
+    "AUTHOR_LOGIN" VARCHAR(255),
+    "ACTION_PLAN_KEY" VARCHAR(50),
+    "ISSUE_ATTRIBUTES" VARCHAR(4000),
+    "EFFORT" INTEGER,
+    "CREATED_AT" BIGINT,
+    "UPDATED_AT" BIGINT,
+    "ISSUE_CREATION_DATE" BIGINT,
+    "ISSUE_UPDATE_DATE" BIGINT,
+    "ISSUE_CLOSE_DATE" BIGINT,
+    "TAGS" VARCHAR(4000),
+    "COMPONENT_UUID" VARCHAR(50),
+    "PROJECT_UUID" VARCHAR(50),
+    "LOCATIONS" BLOB,
+    "ISSUE_TYPE" TINYINT,
+    "FROM_HOTSPOT" BOOLEAN
+);
+ALTER TABLE "ISSUES" ADD CONSTRAINT "PK_ISSUES" PRIMARY KEY("ID");
+CREATE INDEX "ISSUES_ASSIGNEE" ON "ISSUES"("ASSIGNEE");
+CREATE INDEX "ISSUES_COMPONENT_UUID" ON "ISSUES"("COMPONENT_UUID");
+CREATE INDEX "ISSUES_CREATION_DATE" ON "ISSUES"("ISSUE_CREATION_DATE");
+CREATE UNIQUE INDEX "ISSUES_KEE" ON "ISSUES"("KEE");
+CREATE INDEX "ISSUES_PROJECT_UUID" ON "ISSUES"("PROJECT_UUID");
+CREATE INDEX "ISSUES_RESOLUTION" ON "ISSUES"("RESOLUTION");
+CREATE INDEX "ISSUES_RULE_ID" ON "ISSUES"("RULE_ID");
+CREATE INDEX "ISSUES_UPDATED_AT" ON "ISSUES"("UPDATED_AT");
index eccc9a86d1be5c8f02d97c0783e5be4574d9ccda..48a10c0e7a6e8f67dd0959f773ade0031761413d 100644 (file)
@@ -98,9 +98,9 @@ public class ChangelogAction implements IssuesWsAction {
 
   private boolean isMember(DbSession dbSession, IssueDto issue) {
     Optional<ComponentDto> project = dbClient.componentDao().selectByUuid(dbSession, issue.getProjectUuid());
-    checkState(project.isPresent(), "Cannot find the project with uuid %s from issue.id %s", issue.getProjectUuid(), issue.getId());
+    checkState(project.isPresent(), "Cannot find the project with uuid %s from issue with key %s", issue.getProjectUuid(), issue.getKey());
     Optional<OrganizationDto> organization = dbClient.organizationDao().selectByUuid(dbSession, project.get().getOrganizationUuid());
-    checkState(organization.isPresent(), "Cannot find the organization with uuid %s from issue.id %s", project.get().getOrganizationUuid(), issue.getId());
+    checkState(organization.isPresent(), "Cannot find the organization with uuid %s from issue with key %s", project.get().getOrganizationUuid(), issue.getKey());
     return userSession.hasMembership(organization.get());
   }
 }
index eac3db982c771d3b82c01134f3c496e5e0d8b4a4..b0374d6497d9b13671f1efa158b1dab1740afb79 100644 (file)
@@ -35,9 +35,9 @@ public class IssuesFinderSortTest {
 
   @Test
   public void should_sort_by_status() {
-    IssueDto issue1 = new IssueDto().setId(1L).setStatus("CLOSED");
-    IssueDto issue2 = new IssueDto().setId(2L).setStatus("REOPENED");
-    IssueDto issue3 = new IssueDto().setId(3L).setStatus("OPEN");
+    IssueDto issue1 = new IssueDto().setKee("A").setStatus("CLOSED");
+    IssueDto issue2 = new IssueDto().setKee("B").setStatus("REOPENED");
+    IssueDto issue3 = new IssueDto().setKee("C").setStatus("OPEN");
     List<IssueDto> dtoList = newArrayList(issue1, issue2, issue3);
 
     IssueQuery query = IssueQuery.builder().sort(IssueQuery.SORT_BY_STATUS).asc(false).build();
@@ -53,9 +53,9 @@ public class IssuesFinderSortTest {
 
   @Test
   public void should_sort_by_severity() {
-    IssueDto issue1 = new IssueDto().setId(1L).setSeverity("INFO");
-    IssueDto issue2 = new IssueDto().setId(2L).setSeverity("BLOCKER");
-    IssueDto issue3 = new IssueDto().setId(3L).setSeverity("MAJOR");
+    IssueDto issue1 = new IssueDto().setKee("A").setSeverity("INFO");
+    IssueDto issue2 = new IssueDto().setKee("B").setSeverity("BLOCKER");
+    IssueDto issue3 = new IssueDto().setKee("C").setSeverity("MAJOR");
     List<IssueDto> dtoList = newArrayList(issue1, issue2, issue3);
 
     IssueQuery query = IssueQuery.builder().sort(IssueQuery.SORT_BY_SEVERITY).asc(true).build();
@@ -71,9 +71,9 @@ public class IssuesFinderSortTest {
 
   @Test
   public void should_sort_by_desc_severity() {
-    IssueDto issue1 = new IssueDto().setId(1L).setSeverity("INFO");
-    IssueDto issue2 = new IssueDto().setId(2L).setSeverity("BLOCKER");
-    IssueDto issue3 = new IssueDto().setId(3L).setSeverity("MAJOR");
+    IssueDto issue1 = new IssueDto().setKee("A").setSeverity("INFO");
+    IssueDto issue2 = new IssueDto().setKee("B").setSeverity("BLOCKER");
+    IssueDto issue3 = new IssueDto().setKee("C").setSeverity("MAJOR");
     List<IssueDto> dtoList = newArrayList(issue1, issue2, issue3);
 
     IssueQuery query = IssueQuery.builder().sort(IssueQuery.SORT_BY_SEVERITY).asc(false).build();
@@ -93,9 +93,9 @@ public class IssuesFinderSortTest {
     Date date1 = DateUtils.addDays(date, -3);
     Date date2 = DateUtils.addDays(date, -2);
     Date date3 = DateUtils.addDays(date, -1);
-    IssueDto issue1 = new IssueDto().setId(1L).setIssueCreationDate(date1);
-    IssueDto issue2 = new IssueDto().setId(2L).setIssueCreationDate(date3);
-    IssueDto issue3 = new IssueDto().setId(3L).setIssueCreationDate(date2);
+    IssueDto issue1 = new IssueDto().setKee("A").setIssueCreationDate(date1);
+    IssueDto issue2 = new IssueDto().setKee("B").setIssueCreationDate(date3);
+    IssueDto issue3 = new IssueDto().setKee("C").setIssueCreationDate(date2);
     List<IssueDto> dtoList = newArrayList(issue1, issue2, issue3);
 
     IssueQuery query = IssueQuery.builder().sort(IssueQuery.SORT_BY_CREATION_DATE).asc(false).build();
@@ -115,9 +115,9 @@ public class IssuesFinderSortTest {
     Date date1 = DateUtils.addDays(date, -3);
     Date date2 = DateUtils.addDays(date, -2);
     Date date3 = DateUtils.addDays(date, -1);
-    IssueDto issue1 = new IssueDto().setId(1L).setIssueUpdateDate(date1);
-    IssueDto issue2 = new IssueDto().setId(2L).setIssueUpdateDate(date3);
-    IssueDto issue3 = new IssueDto().setId(3L).setIssueUpdateDate(date2);
+    IssueDto issue1 = new IssueDto().setKee("A").setIssueUpdateDate(date1);
+    IssueDto issue2 = new IssueDto().setKee("B").setIssueUpdateDate(date3);
+    IssueDto issue3 = new IssueDto().setKee("C").setIssueUpdateDate(date2);
     List<IssueDto> dtoList = newArrayList(issue1, issue2, issue3);
 
     IssueQuery query = IssueQuery.builder().sort(IssueQuery.SORT_BY_UPDATE_DATE).asc(false).build();
@@ -137,9 +137,9 @@ public class IssuesFinderSortTest {
     Date date1 = DateUtils.addDays(date, -3);
     Date date2 = DateUtils.addDays(date, -2);
     Date date3 = DateUtils.addDays(date, -1);
-    IssueDto issue1 = new IssueDto().setId(1L).setIssueCloseDate(date1);
-    IssueDto issue2 = new IssueDto().setId(2L).setIssueCloseDate(date3);
-    IssueDto issue3 = new IssueDto().setId(3L).setIssueCloseDate(date2);
+    IssueDto issue1 = new IssueDto().setKee("A").setIssueCloseDate(date1);
+    IssueDto issue2 = new IssueDto().setKee("B").setIssueCloseDate(date3);
+    IssueDto issue3 = new IssueDto().setKee("C").setIssueCloseDate(date2);
     List<IssueDto> dtoList = newArrayList(issue1, issue2, issue3);
 
     IssueQuery query = IssueQuery.builder().sort(IssueQuery.SORT_BY_CLOSE_DATE).asc(false).build();
@@ -155,10 +155,10 @@ public class IssuesFinderSortTest {
 
   @Test
   public void should_not_sort_with_null_sort() {
-    IssueDto issue1 = new IssueDto().setId(1L).setAssigneeUuid("perceval");
-    IssueDto issue2 = new IssueDto().setId(2L).setAssigneeUuid("arthur");
-    IssueDto issue3 = new IssueDto().setId(3L).setAssigneeUuid("vincent");
-    IssueDto issue4 = new IssueDto().setId(4L).setAssigneeUuid(null);
+    IssueDto issue1 = new IssueDto().setKee("A").setAssigneeUuid("perceval");
+    IssueDto issue2 = new IssueDto().setKee("B").setAssigneeUuid("arthur");
+    IssueDto issue3 = new IssueDto().setKee("C").setAssigneeUuid("vincent");
+    IssueDto issue4 = new IssueDto().setKee("D").setAssigneeUuid(null);
     List<IssueDto> dtoList = newArrayList(issue1, issue2, issue3, issue4);
 
     IssueQuery query = IssueQuery.builder().sort(null).build();