]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-7496 drop unused columns on Issues table
authorPierre <pierre.guillot@sonarsource.com>
Tue, 22 Feb 2022 15:00:47 +0000 (16:00 +0100)
committersonartech <sonartech@sonarsource.com>
Thu, 24 Feb 2022 20:02:52 +0000 (20:02 +0000)
34 files changed:
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/issue/IssueLifecycle.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/util/cache/ProtobufIssueDiskCache.java
server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectexport/issue/ExportIssuesStep.java
server/sonar-ce-task-projectanalysis/src/main/protobuf/issue_cache.proto
server/sonar-ce-task-projectanalysis/src/main/protobuf/project_dump.proto
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/IssueLifecycleTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectexport/issue/ExportIssuesStepTest.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/IssueDtoTest.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/MigrationConfigurationModule.java
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v94/AbstractDropColumn.java [new file with mode: 0644]
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v94/DbVersion94.java [new file with mode: 0644]
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v94/DropActionPlanKeyIssueColumn.java [new file with mode: 0644]
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v94/DropIssuesAttributesIssueColumn.java [new file with mode: 0644]
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v94/DropReporterIssueColumn.java [new file with mode: 0644]
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v94/package-info.java [new file with mode: 0644]
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v94/DbVersion94Test.java [new file with mode: 0644]
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v94/DropActionPlanKeyIssueColumnTest.java [new file with mode: 0644]
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v94/DropIssuesAttributesIssueColumnTest.java [new file with mode: 0644]
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v94/DropReporterIssueColumnTest.java [new file with mode: 0644]
server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v94/DropActionPlanKeyIssueColumnTest/schema.sql [new file with mode: 0644]
server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v94/DropIssuesAttributesIssueColumnTest/schema.sql [new file with mode: 0644]
server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v94/DropReporterIssueColumnTest/schema.sql [new file with mode: 0644]
server/sonar-server-common/src/main/java/org/sonar/server/issue/IssueFieldsSetter.java
server/sonar-server-common/src/test/java/org/sonar/server/issue/IssueFieldsSetterTest.java
server/sonar-server-common/src/test/java/org/sonar/server/issue/index/IssueIteratorFactoryTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/WebIssueStorageTest.java
sonar-core/src/main/java/org/sonar/core/issue/DefaultIssue.java
sonar-core/src/test/java/org/sonar/core/issue/DefaultIssueTest.java
sonar-plugin-api/src/main/java/org/sonar/api/issue/Issue.java

index b57b06cbd0096b0167f6f0b3dd8b4734e31b5c18..9c369e4c5110b68204ccff778fdd47a86a0cbb8f 100644 (file)
@@ -214,7 +214,6 @@ public class IssueLifecycle {
     toIssue.setAssigneeUuid(fromIssue.assignee());
     toIssue.setAuthorLogin(fromIssue.authorLogin());
     toIssue.setTags(fromIssue.tags());
-    toIssue.setAttributes(fromIssue.attributes());
     toIssue.setEffort(debtCalculator.calculate(toIssue));
     toIssue.setOnDisabledRule(fromIssue.isOnDisabledRule());
     toIssue.setSelectedAt(fromIssue.selectedAt());
index 32abede0c8942eeccf1a0b21752c150770f8f70c..452751ba1ceb035aaccf3409861b6fc23dde0283 100644 (file)
@@ -112,7 +112,6 @@ public class ProtobufIssueDiskCache implements DiskCache<DefaultIssue> {
     defaultIssue.setResolution(next.hasResolution() ? next.getResolution() : null);
     defaultIssue.setAssigneeUuid(next.hasAssigneeUuid() ? next.getAssigneeUuid() : null);
     defaultIssue.setChecksum(next.hasChecksum() ? next.getChecksum() : null);
-    defaultIssue.setAttributes(next.getAttributesMap());
     defaultIssue.setAuthorLogin(next.hasAuthorLogin() ? next.getAuthorLogin() : null);
     next.getCommentsList().forEach(c -> defaultIssue.addComment(toDefaultIssueComment(c)));
     defaultIssue.setTags(ImmutableSet.copyOf(TAGS_SPLITTER.split(next.getTags())));
@@ -163,7 +162,6 @@ public class ProtobufIssueDiskCache implements DiskCache<DefaultIssue> {
     ofNullable(defaultIssue.resolution()).ifPresent(builder::setResolution);
     ofNullable(defaultIssue.assignee()).ifPresent(builder::setAssigneeUuid);
     ofNullable(defaultIssue.checksum()).ifPresent(builder::setChecksum);
-    ofNullable(defaultIssue.attributes()).ifPresent(builder::putAllAttributes);
     ofNullable(defaultIssue.authorLogin()).ifPresent(builder::setAuthorLogin);
     defaultIssue.defaultIssueComments().forEach(c -> builder.addComments(toProtoComment(c)));
     ofNullable(defaultIssue.tags()).ifPresent(t -> builder.setTags(String.join(TAGS_SEPARATOR, t)));
index 4aff16330fb6afaff6565b020ce638ca2aef388d..0351bd6c1a0d8c6335efebca5da96e042a51093b 100644 (file)
@@ -55,7 +55,7 @@ public class ExportIssuesStep implements ComputationStep {
     " i.kee, r.uuid, r.plugin_rule_key, r.plugin_name, i.issue_type," +
     " i.component_uuid, i.message, i.line, i.checksum, i.status," +
     " i.resolution, i.severity, i.manual_severity, i.gap, effort," +
-    " i.assignee, i.author_login, i.tags, i.issue_attributes, i.issue_creation_date," +
+    " i.assignee, i.author_login, i.tags, i.issue_creation_date," +
     " i.issue_update_date, i.issue_close_date, i.locations, i.project_uuid" +
     " from issues i" +
     " join rules r on r.uuid = i.rule_uuid and r.status <> ?" +
@@ -140,11 +140,10 @@ public class ExportIssuesStep implements ComputationStep {
       .setAssignee(emptyIfNull(rs, 16))
       .setAuthor(emptyIfNull(rs, 17))
       .setTags(emptyIfNull(rs, 18))
-      .setAttributes(emptyIfNull(rs, 19))
-      .setIssueCreatedAt(rs.getLong(20))
-      .setIssueUpdatedAt(rs.getLong(21))
-      .setIssueClosedAt(rs.getLong(22))
-      .setProjectUuid(rs.getString(24));
+      .setIssueCreatedAt(rs.getLong(19))
+      .setIssueUpdatedAt(rs.getLong(20))
+      .setIssueClosedAt(rs.getLong(21))
+      .setProjectUuid(rs.getString(23));
     setLocations(builder, rs, issueUuid);
     return builder.build();
   }
@@ -158,7 +157,7 @@ public class ExportIssuesStep implements ComputationStep {
 
   private static void setLocations(ProjectDump.Issue.Builder builder, ResultSet rs, String issueUuid) throws SQLException {
     try {
-      byte[] bytes = rs.getBytes(23);
+      byte[] bytes = rs.getBytes(22);
       if (bytes != null) {
         // fail fast, ensure we can read data from DB
         DbIssues.Locations.parseFrom(bytes);
index 29bce80c2813af9eb29dd0847afb4c517e4abb0b..dbd6942998a24ac9733beb3bbeef0b746c394d7f 100644 (file)
@@ -49,7 +49,6 @@ message Issue {
   optional string resolution = 18;
   optional string assigneeUuid = 19;
   optional string checksum = 20;
-  map<string, string> attributes = 21;
   optional string authorLogin = 22;
   optional string tags = 23;
   optional sonarqube.db.issues.Locations locations = 24;
index 170f8a48b6e6de51adc45b135c19ed6918357f41..358d1041e0b2bd03ebb407167e7ae9d65aefac83 100644 (file)
@@ -114,7 +114,7 @@ message Issue {
   string author = 16;
 
   string tags = 17;
-  string attributes = 18;
+
   // issue dates
   int64 issue_created_at = 19;
   int64 issue_updated_at = 20;
index 5982891b32d916cac8c08d5124134d719bc71f4a..c1f1e06bfff7bbb1bab9b350699a00c9954a2b89 100644 (file)
@@ -19,7 +19,6 @@
  */
 package org.sonar.ce.task.projectanalysis.issue;
 
-import com.google.common.collect.ImmutableMap;
 import java.util.Date;
 import org.junit.Rule;
 import org.junit.Test;
@@ -415,22 +414,4 @@ public class IssueLifecycleTest {
 
     assertThat(raw.isChanged()).isTrue();
   }
-
-  @Test
-  public void mergeExistingOpenIssue_with_attributes() {
-    DefaultIssue raw = new DefaultIssue()
-      .setNew(true)
-      .setKey("RAW_KEY")
-      .setRuleKey(XOO_X1);
-    DefaultIssue base = new DefaultIssue()
-      .setKey("BASE_KEY")
-      .setResolution(RESOLUTION_FIXED)
-      .setStatus(STATUS_CLOSED)
-      .setSeverity(BLOCKER)
-      .setAttributes(ImmutableMap.of("JIRA", "SONAR-01"));
-
-    underTest.mergeExistingOpenIssue(raw, base);
-
-    assertThat(raw.attributes()).containsEntry("JIRA", "SONAR-01");
-  }
 }
index 8b39c16f368ec153debc9a7c67a2f7e8302c78db..2a3214ae0473a04d2ed0122de4d044d77b530b6c 100644 (file)
@@ -219,7 +219,6 @@ public class ExportIssuesStepTest {
       .setAssigneeUuid("assignee-uuid")
       .setAuthorLogin("author")
       .setTagsString("tags")
-      .setIssueAttributes("attributes")
       .setIssueCreationTime(963L)
       .setIssueUpdateTime(852L)
       .setIssueCloseTime(741L);
@@ -252,7 +251,6 @@ public class ExportIssuesStepTest {
     assertThat(issue.getAssignee()).isEqualTo(issueDto.getAssigneeUuid());
     assertThat(issue.getAuthor()).isEqualTo(issueDto.getAuthorLogin());
     assertThat(issue.getTags()).isEqualTo(issueDto.getTagsString());
-    assertThat(issue.getAttributes()).isEqualTo(issueDto.getIssueAttributes());
     assertThat(issue.getIssueCreatedAt()).isEqualTo(issueDto.getIssueCreationTime());
     assertThat(issue.getIssueUpdatedAt()).isEqualTo(issueDto.getIssueUpdateTime());
     assertThat(issue.getIssueClosedAt()).isEqualTo(issueDto.getIssueCloseTime());
index 1bc4e5f0b60dcf3142fba2fb79a26a9d3932e611..a4a97c4c7de576691f1db83e62bfd053fe8e6438 100644 (file)
@@ -20,7 +20,6 @@
 package org.sonar.db.issue;
 
 import com.google.common.base.Joiner;
-import com.google.common.base.MoreObjects;
 import com.google.common.base.Preconditions;
 import com.google.common.base.Splitter;
 import com.google.common.collect.ImmutableSet;
@@ -37,7 +36,6 @@ import org.apache.commons.lang.builder.ToStringStyle;
 import org.sonar.api.rule.RuleKey;
 import org.sonar.api.rules.RuleType;
 import org.sonar.api.utils.Duration;
-import org.sonar.api.utils.KeyValueFormat;
 import org.sonar.core.issue.DefaultIssue;
 import org.sonar.db.component.ComponentDto;
 import org.sonar.db.protobuf.DbIssues;
@@ -71,7 +69,6 @@ public final class IssueDto implements Serializable {
   private String assigneeUuid;
   private String assigneeLogin;
   private String authorLogin;
-  private String issueAttributes;
   private String securityStandards;
   private byte[] locations;
   private long createdAt;
@@ -135,7 +132,6 @@ public final class IssueDto implements Serializable {
       .setModuleUuidPath(issue.moduleUuidPath())
       .setProjectUuid(issue.projectUuid())
       .setProjectKey(issue.projectKey())
-      .setIssueAttributes(KeyValueFormat.format(issue.attributes()))
       .setAuthorLogin(issue.authorLogin())
       .setIssueCreationDate(issue.creationDate())
       .setIssueCloseDate(issue.closeDate())
@@ -175,7 +171,6 @@ public final class IssueDto implements Serializable {
       .setChecksum(issue.checksum())
       .setManualSeverity(issue.manualSeverity())
       .setAssigneeUuid(issue.assignee())
-      .setIssueAttributes(KeyValueFormat.format(issue.attributes()))
       .setAuthorLogin(issue.authorLogin())
       .setRuleKey(issue.ruleKey().repository(), issue.ruleKey().rule())
       .setExternal(issue.isFromExternalRuleEngine())
@@ -365,17 +360,6 @@ public final class IssueDto implements Serializable {
     return this;
   }
 
-  @CheckForNull
-  public String getIssueAttributes() {
-    return issueAttributes;
-  }
-
-  public IssueDto setIssueAttributes(@Nullable String s) {
-    checkArgument(s == null || s.length() <= 4000, "Value is too long for issue attributes: %s", s);
-    this.issueAttributes = s;
-    return this;
-  }
-
   public IssueDto setSecurityStandards(@Nullable String s) {
     this.securityStandards = s;
     return this;
@@ -751,7 +735,6 @@ public final class IssueDto implements Serializable {
     issue.setChecksum(checksum);
     issue.setSeverity(severity);
     issue.setAssigneeUuid(assigneeUuid);
-    issue.setAttributes(KeyValueFormat.parse(MoreObjects.firstNonNull(issueAttributes, "")));
     issue.setComponentKey(componentKey);
     issue.setComponentUuid(componentUuid);
     issue.setModuleUuid(moduleUuid);
index 6f96b1ff85489d00c080e4979235150a7fa586a4..5a64c24b5ea1e6e4a64f524014bde13e929afd63 100644 (file)
@@ -20,7 +20,6 @@
     i.assignee as assigneeUuid,
     i.author_login as authorLogin,
     i.tags as tagsString,
-    i.issue_attributes as issueAttributes,
     i.issue_creation_date as issueCreationTime,
     i.issue_update_date as issueUpdateTime,
     i.issue_close_date as issueCloseTime,
@@ -59,7 +58,6 @@
     i.assignee,
     i.author_login,
     i.tags,
-    i.issue_attributes,
     i.issue_creation_date,
     i.issue_update_date,
     i.issue_close_date,
   <insert id="insert" parameterType="Issue" useGeneratedKeys="false">
     INSERT INTO issues (kee, rule_uuid, severity, manual_severity,
     message, line, locations, gap, effort, status, tags,
-    resolution, checksum, assignee, author_login, issue_attributes, issue_creation_date, issue_update_date,
+    resolution, checksum, assignee, author_login, issue_creation_date, issue_update_date,
     issue_close_date, created_at, updated_at, component_uuid, project_uuid, issue_type, quick_fix_available)
     VALUES (
     #{kee,jdbcType=VARCHAR},
     #{checksum,jdbcType=VARCHAR},
     #{assigneeUuid,jdbcType=VARCHAR},
     #{authorLogin,jdbcType=VARCHAR},
-    #{issueAttributes,jdbcType=VARCHAR},
     #{issueCreationTime,jdbcType=BIGINT},#{issueUpdateTime,jdbcType=BIGINT}, #{issueCloseTime,jdbcType=BIGINT},
     #{createdAt,jdbcType=BIGINT}, #{updatedAt,jdbcType=BIGINT},
     #{componentUuid,jdbcType=VARCHAR}, #{projectUuid,jdbcType=VARCHAR}, #{type,jdbcType=INTEGER},
     author_login=#{authorLogin,jdbcType=VARCHAR},
     tags=#{tagsString,jdbcType=VARCHAR},
     project_uuid=#{projectUuid,jdbcType=VARCHAR},
-    issue_attributes=#{issueAttributes,jdbcType=VARCHAR},
     issue_creation_date=#{issueCreationTime,jdbcType=BIGINT},
     issue_update_date=#{issueUpdateTime,jdbcType=BIGINT},
     issue_close_date=#{issueCloseTime,jdbcType=BIGINT},
     tags=#{tagsString,jdbcType=VARCHAR},
     component_uuid=#{componentUuid,jdbcType=VARCHAR},
     project_uuid=#{projectUuid,jdbcType=VARCHAR},
-    issue_attributes=#{issueAttributes,jdbcType=VARCHAR},
     issue_creation_date=#{issueCreationTime,jdbcType=BIGINT},
     issue_update_date=#{issueUpdateTime,jdbcType=BIGINT},
     issue_close_date=#{issueCloseTime,jdbcType=BIGINT},
index cea68962a96ab7ae0a398369d4cc9caa388ddb0c..7d0350a8626135f1f5a2e295912e9fac712c7651 100644 (file)
@@ -411,11 +411,8 @@ CREATE TABLE "ISSUES"(
     "STATUS" CHARACTER VARYING(20),
     "RESOLUTION" CHARACTER VARYING(20),
     "CHECKSUM" CHARACTER VARYING(1000),
-    "REPORTER" CHARACTER VARYING(255),
     "ASSIGNEE" CHARACTER VARYING(255),
     "AUTHOR_LOGIN" CHARACTER VARYING(255),
-    "ACTION_PLAN_KEY" CHARACTER VARYING(50),
-    "ISSUE_ATTRIBUTES" CHARACTER VARYING(4000),
     "EFFORT" INTEGER,
     "CREATED_AT" BIGINT,
     "UPDATED_AT" BIGINT,
index 23210072dcfa0df68de1af28a7015d0649f1da44..094d5023745b2118f8b02a3a4b1a800011bebba5 100644 (file)
@@ -93,7 +93,6 @@ public class IssueDaoTest {
     assertThat(issue.getChecksum()).isEqualTo("123456789");
     assertThat(issue.getAuthorLogin()).isEqualTo("morgan");
     assertThat(issue.getAssigneeUuid()).isEqualTo("karadoc");
-    assertThat(issue.getIssueAttributes()).isEqualTo("JIRA=FOO-1234");
     assertThat(issue.getIssueCreationDate()).isNotNull();
     assertThat(issue.getIssueUpdateDate()).isNotNull();
     assertThat(issue.getIssueCloseDate()).isNotNull();
@@ -488,7 +487,6 @@ public class IssueDaoTest {
     dto.setSeverity("BLOCKER");
     dto.setAuthorLogin("morgan");
     dto.setAssigneeUuid("karadoc");
-    dto.setIssueAttributes("JIRA=FOO-1234");
     dto.setChecksum("123456789");
     dto.setMessage("the message");
     dto.setCreatedAt(1_440_000_000_000L);
index a709ea2620ed1ca6d4c594d3289c0df2ebc96461..bd153ec25ce2e353f6f8b33d78c8f9a57e49ad31 100644 (file)
@@ -39,20 +39,6 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
 
 public class IssueDtoTest {
 
-
-  @Test
-  public void set_data_check_maximal_length() {
-    assertThatThrownBy(() -> {
-      StringBuilder s = new StringBuilder(4500);
-      for (int i = 0; i < 4500; i++) {
-        s.append('a');
-      }
-      new IssueDto().setIssueAttributes(s.toString());
-    })
-      .isInstanceOf(IllegalArgumentException.class)
-      .hasMessageContaining("Value is too long for issue attributes:");
-  }
-
   @Test
   public void set_issue_fields() {
     Date createdAt = DateUtils.addDays(new Date(), -5);
@@ -80,7 +66,6 @@ public class IssueDtoTest {
       .setMessage("message")
       .setManualSeverity(true)
       .setAssigneeUuid("perceval")
-      .setIssueAttributes("key=value")
       .setAuthorLogin("pierre")
       .setIssueCreationDate(createdAt)
       .setIssueUpdateDate(updatedAt)
@@ -106,7 +91,6 @@ public class IssueDtoTest {
     assertThat(issue.message()).isEqualTo("message");
     assertThat(issue.manualSeverity()).isTrue();
     assertThat(issue.assignee()).isEqualTo("perceval");
-    assertThat(issue.attribute("key")).isEqualTo("value");
     assertThat(issue.authorLogin()).isEqualTo("pierre");
     assertThat(issue.creationDate()).isEqualTo(DateUtils.truncate(createdAt, Calendar.SECOND));
     assertThat(issue.updateDate()).isEqualTo(DateUtils.truncate(updatedAt, Calendar.SECOND));
@@ -177,10 +161,10 @@ public class IssueDtoTest {
 
     assertThat(issueDto).extracting(IssueDto::isManualSeverity, IssueDto::getChecksum, IssueDto::getAssigneeUuid,
       IssueDto::isExternal, IssueDto::getComponentUuid, IssueDto::getComponentKey, IssueDto::getModuleUuid,
-      IssueDto::getModuleUuidPath, IssueDto::getProjectUuid, IssueDto::getProjectKey, IssueDto::getIssueAttributes,
+      IssueDto::getModuleUuidPath, IssueDto::getProjectUuid, IssueDto::getProjectKey,
       IssueDto::getRuleUuid)
       .containsExactly(true, "123", "123", true, "123", "componentKey", "moduleUuid",
-        "path/to/module/uuid", "123", "projectKey", "key=value", "ruleUuid");
+        "path/to/module/uuid", "123", "projectKey", "ruleUuid");
 
     assertThat(issueDto.isQuickFixAvailable()).isTrue();
     assertThat(issueDto.isNewCodeReferenceIssue()).isTrue();
@@ -210,9 +194,9 @@ public class IssueDtoTest {
 
     assertThat(issueDto).extracting(IssueDto::isManualSeverity, IssueDto::getChecksum, IssueDto::getAssigneeUuid,
       IssueDto::isExternal, IssueDto::getComponentUuid, IssueDto::getComponentKey, IssueDto::getModuleUuid,
-      IssueDto::getModuleUuidPath, IssueDto::getProjectUuid, IssueDto::getProjectKey, IssueDto::getIssueAttributes)
+      IssueDto::getModuleUuidPath, IssueDto::getProjectUuid, IssueDto::getProjectKey)
       .containsExactly(true, "123", "123", true, "123", "componentKey", "moduleUuid",
-        "path/to/module/uuid", "123", "projectKey", "key=value");
+        "path/to/module/uuid", "123", "projectKey");
 
     assertThat(issueDto.isQuickFixAvailable()).isTrue();
     assertThat(issueDto.isNewCodeReferenceIssue()).isTrue();
@@ -241,7 +225,6 @@ public class IssueDtoTest {
       .setModuleUuidPath("path/to/module/uuid")
       .setProjectUuid("123")
       .setProjectKey("projectKey")
-      .setAttribute("key", "value")
       .setAuthorLogin("admin")
       .setCreationDate(dateNow)
       .setCloseDate(dateNow)
index 913af6ec66893abe65ecd278fef512c87b132899..b50f7de1d43262741650141961911c70a0eb2fd0 100644 (file)
@@ -102,7 +102,6 @@ public class IssueMapperTest {
     assertThat(result.getSeverity()).isEqualTo("BLOCKER");
     assertThat(result.getAuthorLogin()).isEqualTo("morgan");
     assertThat(result.getAssigneeUuid()).isEqualTo("karadoc");
-    assertThat(result.getIssueAttributes()).isEqualTo("JIRA=FOO-1234");
     assertThat(result.getChecksum()).isEqualTo("123456789");
     assertThat(result.getMessage()).isEqualTo("the message");
     assertThat(result.getIssueCreationTime()).isEqualTo(1_401_000_000_000L);
@@ -132,7 +131,6 @@ public class IssueMapperTest {
     update.setSeverity("BLOCKER");
     update.setAuthorLogin("morgan");
     update.setAssigneeUuid("karadoc");
-    update.setIssueAttributes("JIRA=FOO-1234");
     update.setChecksum("123456789");
     update.setMessage("the message");
 
@@ -161,7 +159,6 @@ public class IssueMapperTest {
     assertThat(result.getSeverity()).isEqualTo("BLOCKER");
     assertThat(result.getAuthorLogin()).isEqualTo("morgan");
     assertThat(result.getAssigneeUuid()).isEqualTo("karadoc");
-    assertThat(result.getIssueAttributes()).isEqualTo("JIRA=FOO-1234");
     assertThat(result.getChecksum()).isEqualTo("123456789");
     assertThat(result.getMessage()).isEqualTo("the message");
     assertThat(result.getIssueCreationTime()).isEqualTo(1_550_000_000_000L);
@@ -538,7 +535,6 @@ public class IssueMapperTest {
       .setSeverity("BLOCKER")
       .setAuthorLogin("morgan")
       .setAssigneeUuid("karadoc")
-      .setIssueAttributes("JIRA=FOO-1234")
       .setChecksum("123456789")
       .setMessage("the message")
       .setIssueCreationTime(1_401_000_000_000L)
index a6e8762c030fb555c2e2ed515be94e61a2fed1cf..2561b5aa59b81f26965b8e1fdd2093ae4e711f9e 100644 (file)
@@ -32,6 +32,7 @@ import org.sonar.server.platform.db.migration.version.v90.DbVersion90;
 import org.sonar.server.platform.db.migration.version.v91.DbVersion91;
 import org.sonar.server.platform.db.migration.version.v92.DbVersion92;
 import org.sonar.server.platform.db.migration.version.v93.DbVersion93;
+import org.sonar.server.platform.db.migration.version.v94.DbVersion94;
 
 public class MigrationConfigurationModule extends Module {
   @Override
@@ -44,6 +45,7 @@ public class MigrationConfigurationModule extends Module {
       DbVersion91.class,
       DbVersion92.class,
       DbVersion93.class,
+      DbVersion94.class,
 
       // migration steps
       MigrationStepRegistryImpl.class,
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v94/AbstractDropColumn.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v94/AbstractDropColumn.java
new file mode 100644 (file)
index 0000000..be59801
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2022 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.v94;
+
+import java.sql.SQLException;
+import org.sonar.db.Database;
+import org.sonar.db.DatabaseUtils;
+import org.sonar.server.platform.db.migration.sql.DropColumnsBuilder;
+import org.sonar.server.platform.db.migration.step.DdlChange;
+
+public abstract class AbstractDropColumn extends DdlChange {
+
+  private final String tableName;
+  private final String columnName;
+
+  protected AbstractDropColumn(Database db, String tableName, String columnName) {
+    super(db);
+    this.tableName = tableName;
+    this.columnName = columnName;
+  }
+
+  @Override
+  public void execute(DdlChange.Context context) throws SQLException {
+    if (!checkIfUseManagedColumnExists()) {
+      return;
+    }
+
+    context.execute(new DropColumnsBuilder(getDatabase().getDialect(), tableName, columnName).build());
+  }
+
+  private boolean checkIfUseManagedColumnExists() throws SQLException {
+    try (var connection = getDatabase().getDataSource().getConnection()) {
+      if (DatabaseUtils.tableColumnExists(connection, tableName, columnName)) {
+        return true;
+      }
+    }
+    return false;
+  }
+
+}
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v94/DbVersion94.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v94/DbVersion94.java
new file mode 100644 (file)
index 0000000..2d72af9
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2022 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.v94;
+
+import org.sonar.server.platform.db.migration.step.MigrationStepRegistry;
+import org.sonar.server.platform.db.migration.version.DbVersion;
+
+public class DbVersion94 implements DbVersion {
+  @Override
+  public void addSteps(MigrationStepRegistry registry) {
+    registry
+      .add(6301, "Drop unused Issues Column REPORTER", DropReporterIssueColumn.class)
+      .add(6302, "Drop unused Issues Column ACTION_PLAN_KEY", DropActionPlanKeyIssueColumn.class)
+      .add(6303, "Drop unused Issues Column ISSUE_ATTRIBUTES", DropIssuesAttributesIssueColumn.class)
+
+    ;
+  }
+}
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v94/DropActionPlanKeyIssueColumn.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v94/DropActionPlanKeyIssueColumn.java
new file mode 100644 (file)
index 0000000..9ba82a5
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2022 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.v94;
+
+import org.sonar.db.Database;
+
+public class DropActionPlanKeyIssueColumn extends AbstractDropColumn {
+
+  public static final String TABLE_NAME = "issues";
+  public static final String COLUMN_NAME = "action_plan_key";
+
+  public DropActionPlanKeyIssueColumn(Database db) {
+    super(db, TABLE_NAME, COLUMN_NAME);
+  }
+}
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v94/DropIssuesAttributesIssueColumn.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v94/DropIssuesAttributesIssueColumn.java
new file mode 100644 (file)
index 0000000..9736310
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2022 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.v94;
+
+import org.sonar.db.Database;
+
+public class DropIssuesAttributesIssueColumn extends AbstractDropColumn{
+
+  public static final String TABLE_NAME = "issues";
+  public static final String COLUMN_NAME = "issue_attributes";
+
+  public DropIssuesAttributesIssueColumn(Database db) {
+    super(db, TABLE_NAME, COLUMN_NAME);
+  }
+
+}
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v94/DropReporterIssueColumn.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v94/DropReporterIssueColumn.java
new file mode 100644 (file)
index 0000000..9049308
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2022 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.v94;
+
+import org.sonar.db.Database;
+
+public class DropReporterIssueColumn extends AbstractDropColumn {
+
+  public static final String TABLE_NAME = "issues";
+  public static final String COLUMN_NAME = "reporter";
+
+  public DropReporterIssueColumn(Database db) {
+    super(db, TABLE_NAME, COLUMN_NAME);
+  }
+
+}
diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v94/package-info.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v94/package-info.java
new file mode 100644 (file)
index 0000000..b593ed7
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2022 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.
+ */
+@ParametersAreNonnullByDefault
+package org.sonar.server.platform.db.migration.version.v94;
+
+import javax.annotation.ParametersAreNonnullByDefault;
+
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v94/DbVersion94Test.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v94/DbVersion94Test.java
new file mode 100644 (file)
index 0000000..b578298
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2022 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.v94;
+
+import org.junit.Test;
+
+import static org.sonar.server.platform.db.migration.version.DbVersionTestUtils.verifyMigrationNotEmpty;
+import static org.sonar.server.platform.db.migration.version.DbVersionTestUtils.verifyMinimumMigrationNumber;
+
+public class DbVersion94Test {
+
+  private final DbVersion94 underTest = new DbVersion94();
+
+  @Test
+  public void migrationNumber_starts_at_6301() {
+    verifyMinimumMigrationNumber(underTest, 6301);
+  }
+
+  @Test
+  public void verify_migration_count() {
+    verifyMigrationNotEmpty(underTest);
+  }
+
+}
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v94/DropActionPlanKeyIssueColumnTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v94/DropActionPlanKeyIssueColumnTest.java
new file mode 100644 (file)
index 0000000..e935d8d
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2022 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.v94;
+
+import java.sql.SQLException;
+import java.sql.Types;
+import org.junit.Rule;
+import org.junit.Test;
+import org.sonar.db.CoreDbTester;
+import org.sonar.server.platform.db.migration.step.DdlChange;
+
+public class DropActionPlanKeyIssueColumnTest {
+
+  private static final String COLUMN_NAME = "action_plan_key";
+  private static final String TABLE_NAME = "issues";
+
+  @Rule
+  public final CoreDbTester db = CoreDbTester.createForSchema(DropActionPlanKeyIssueColumnTest.class, "schema.sql");
+
+  private final DdlChange underTest = new DropActionPlanKeyIssueColumn(db.database());
+
+  @Test
+  public void migration_should_drop_action_plan_column() throws SQLException {
+    db.assertColumnDefinition(TABLE_NAME, COLUMN_NAME, Types.VARCHAR, 50, true);
+    underTest.execute();
+    db.assertColumnDoesNotExist(TABLE_NAME, COLUMN_NAME);
+  }
+
+  @Test
+  public void migration_should_be_reentrant() throws SQLException {
+    db.assertColumnDefinition(TABLE_NAME, COLUMN_NAME, Types.VARCHAR, 50, true);
+    underTest.execute();
+    // re-entrant
+    underTest.execute();
+    db.assertColumnDoesNotExist(TABLE_NAME, COLUMN_NAME);
+  }
+
+}
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v94/DropIssuesAttributesIssueColumnTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v94/DropIssuesAttributesIssueColumnTest.java
new file mode 100644 (file)
index 0000000..a8f2840
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2022 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.v94;
+
+import java.sql.SQLException;
+import java.sql.Types;
+import org.junit.Rule;
+import org.junit.Test;
+import org.sonar.db.CoreDbTester;
+import org.sonar.server.platform.db.migration.step.DdlChange;
+
+public class DropIssuesAttributesIssueColumnTest {
+
+  private static final String COLUMN_NAME = "issue_attributes";
+  private static final String TABLE_NAME = "issues";
+
+  @Rule
+  public final CoreDbTester db = CoreDbTester.createForSchema(DropIssuesAttributesIssueColumnTest.class, "schema.sql");
+
+  private final DdlChange underTest = new DropIssuesAttributesIssueColumn(db.database());
+
+  @Test
+  public void migration_should_drop_action_plan_column() throws SQLException {
+    db.assertColumnDefinition(TABLE_NAME, COLUMN_NAME, Types.VARCHAR, 4000, true);
+    underTest.execute();
+    db.assertColumnDoesNotExist(TABLE_NAME, COLUMN_NAME);
+  }
+
+  @Test
+  public void migration_should_be_reentrant() throws SQLException {
+    db.assertColumnDefinition(TABLE_NAME, COLUMN_NAME, Types.VARCHAR, 4000, true);
+    underTest.execute();
+    // re-entrant
+    underTest.execute();
+    db.assertColumnDoesNotExist(TABLE_NAME, COLUMN_NAME);
+  }
+
+}
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v94/DropReporterIssueColumnTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v94/DropReporterIssueColumnTest.java
new file mode 100644 (file)
index 0000000..a0b4618
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2022 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.v94;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.sonar.db.CoreDbTester;
+import org.sonar.server.platform.db.migration.step.DdlChange;
+
+import java.sql.SQLException;
+import java.sql.Types;
+
+public class DropReporterIssueColumnTest {
+
+  private static final String COLUMN_NAME = "reporter";
+  private static final String TABLE_NAME = "issues";
+
+  @Rule
+  public final CoreDbTester db = CoreDbTester.createForSchema(DropReporterIssueColumnTest.class, "schema.sql");
+
+  private final DdlChange underTest = new DropReporterIssueColumn(db.database());
+
+  @Test
+  public void migration_should_drop_action_plan_column() throws SQLException {
+    db.assertColumnDefinition(TABLE_NAME, COLUMN_NAME, Types.VARCHAR, 255, true);
+    underTest.execute();
+    db.assertColumnDoesNotExist(TABLE_NAME, COLUMN_NAME);
+  }
+
+  @Test
+  public void migration_should_be_reentrant() throws SQLException {
+    db.assertColumnDefinition(TABLE_NAME, COLUMN_NAME, Types.VARCHAR, 255, true);
+    underTest.execute();
+    // re-entrant
+    underTest.execute();
+    db.assertColumnDoesNotExist(TABLE_NAME, COLUMN_NAME);
+  }
+
+}
diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v94/DropActionPlanKeyIssueColumnTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v94/DropActionPlanKeyIssueColumnTest/schema.sql
new file mode 100644 (file)
index 0000000..f3934af
--- /dev/null
@@ -0,0 +1,37 @@
+CREATE TABLE "ISSUES"(
+    "KEE" CHARACTER VARYING(50) NOT NULL,
+    "RULE_UUID" CHARACTER VARYING(40),
+    "SEVERITY" CHARACTER VARYING(10),
+    "MANUAL_SEVERITY" BOOLEAN NOT NULL,
+    "MESSAGE" CHARACTER VARYING(4000),
+    "LINE" INTEGER,
+    "GAP" DOUBLE PRECISION,
+    "STATUS" CHARACTER VARYING(20),
+    "RESOLUTION" CHARACTER VARYING(20),
+    "CHECKSUM" CHARACTER VARYING(1000),
+    "ASSIGNEE" CHARACTER VARYING(255),
+    "AUTHOR_LOGIN" CHARACTER VARYING(255),
+    "ACTION_PLAN_KEY" CHARACTER VARYING(50),
+    "ISSUE_ATTRIBUTES" CHARACTER VARYING(4000),
+    "EFFORT" INTEGER,
+    "CREATED_AT" BIGINT,
+    "UPDATED_AT" BIGINT,
+    "ISSUE_CREATION_DATE" BIGINT,
+    "ISSUE_UPDATE_DATE" BIGINT,
+    "ISSUE_CLOSE_DATE" BIGINT,
+    "TAGS" CHARACTER VARYING(4000),
+    "COMPONENT_UUID" CHARACTER VARYING(50),
+    "PROJECT_UUID" CHARACTER VARYING(50),
+    "LOCATIONS" BINARY LARGE OBJECT,
+    "ISSUE_TYPE" TINYINT,
+    "FROM_HOTSPOT" BOOLEAN,
+    "QUICK_FIX_AVAILABLE" BOOLEAN
+);
+ALTER TABLE "ISSUES" ADD CONSTRAINT "PK_ISSUES" PRIMARY KEY("KEE");
+CREATE INDEX "ISSUES_ASSIGNEE" ON "ISSUES"("ASSIGNEE" NULLS FIRST);
+CREATE INDEX "ISSUES_COMPONENT_UUID" ON "ISSUES"("COMPONENT_UUID" NULLS FIRST);
+CREATE INDEX "ISSUES_CREATION_DATE" ON "ISSUES"("ISSUE_CREATION_DATE" NULLS FIRST);
+CREATE INDEX "ISSUES_PROJECT_UUID" ON "ISSUES"("PROJECT_UUID" NULLS FIRST);
+CREATE INDEX "ISSUES_RESOLUTION" ON "ISSUES"("RESOLUTION" NULLS FIRST);
+CREATE INDEX "ISSUES_UPDATED_AT" ON "ISSUES"("UPDATED_AT" NULLS FIRST);
+CREATE INDEX "ISSUES_RULE_UUID" ON "ISSUES"("RULE_UUID" NULLS FIRST);
\ No newline at end of file
diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v94/DropIssuesAttributesIssueColumnTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v94/DropIssuesAttributesIssueColumnTest/schema.sql
new file mode 100644 (file)
index 0000000..17635b5
--- /dev/null
@@ -0,0 +1,36 @@
+CREATE TABLE "ISSUES"(
+    "KEE" CHARACTER VARYING(50) NOT NULL,
+    "RULE_UUID" CHARACTER VARYING(40),
+    "SEVERITY" CHARACTER VARYING(10),
+    "MANUAL_SEVERITY" BOOLEAN NOT NULL,
+    "MESSAGE" CHARACTER VARYING(4000),
+    "LINE" INTEGER,
+    "GAP" DOUBLE PRECISION,
+    "STATUS" CHARACTER VARYING(20),
+    "RESOLUTION" CHARACTER VARYING(20),
+    "CHECKSUM" CHARACTER VARYING(1000),
+    "ASSIGNEE" CHARACTER VARYING(255),
+    "AUTHOR_LOGIN" CHARACTER VARYING(255),
+    "ISSUE_ATTRIBUTES" CHARACTER VARYING(4000),
+    "EFFORT" INTEGER,
+    "CREATED_AT" BIGINT,
+    "UPDATED_AT" BIGINT,
+    "ISSUE_CREATION_DATE" BIGINT,
+    "ISSUE_UPDATE_DATE" BIGINT,
+    "ISSUE_CLOSE_DATE" BIGINT,
+    "TAGS" CHARACTER VARYING(4000),
+    "COMPONENT_UUID" CHARACTER VARYING(50),
+    "PROJECT_UUID" CHARACTER VARYING(50),
+    "LOCATIONS" BINARY LARGE OBJECT,
+    "ISSUE_TYPE" TINYINT,
+    "FROM_HOTSPOT" BOOLEAN,
+    "QUICK_FIX_AVAILABLE" BOOLEAN
+);
+ALTER TABLE "ISSUES" ADD CONSTRAINT "PK_ISSUES" PRIMARY KEY("KEE");
+CREATE INDEX "ISSUES_ASSIGNEE" ON "ISSUES"("ASSIGNEE" NULLS FIRST);
+CREATE INDEX "ISSUES_COMPONENT_UUID" ON "ISSUES"("COMPONENT_UUID" NULLS FIRST);
+CREATE INDEX "ISSUES_CREATION_DATE" ON "ISSUES"("ISSUE_CREATION_DATE" NULLS FIRST);
+CREATE INDEX "ISSUES_PROJECT_UUID" ON "ISSUES"("PROJECT_UUID" NULLS FIRST);
+CREATE INDEX "ISSUES_RESOLUTION" ON "ISSUES"("RESOLUTION" NULLS FIRST);
+CREATE INDEX "ISSUES_UPDATED_AT" ON "ISSUES"("UPDATED_AT" NULLS FIRST);
+CREATE INDEX "ISSUES_RULE_UUID" ON "ISSUES"("RULE_UUID" NULLS FIRST);
diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v94/DropReporterIssueColumnTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v94/DropReporterIssueColumnTest/schema.sql
new file mode 100644 (file)
index 0000000..5a11bc2
--- /dev/null
@@ -0,0 +1,38 @@
+CREATE TABLE "ISSUES"(
+    "KEE" CHARACTER VARYING(50) NOT NULL,
+    "RULE_UUID" CHARACTER VARYING(40),
+    "SEVERITY" CHARACTER VARYING(10),
+    "MANUAL_SEVERITY" BOOLEAN NOT NULL,
+    "MESSAGE" CHARACTER VARYING(4000),
+    "LINE" INTEGER,
+    "GAP" DOUBLE PRECISION,
+    "STATUS" CHARACTER VARYING(20),
+    "RESOLUTION" CHARACTER VARYING(20),
+    "CHECKSUM" CHARACTER VARYING(1000),
+    "REPORTER" CHARACTER VARYING(255),
+    "ASSIGNEE" CHARACTER VARYING(255),
+    "AUTHOR_LOGIN" CHARACTER VARYING(255),
+    "ACTION_PLAN_KEY" CHARACTER VARYING(50),
+    "ISSUE_ATTRIBUTES" CHARACTER VARYING(4000),
+    "EFFORT" INTEGER,
+    "CREATED_AT" BIGINT,
+    "UPDATED_AT" BIGINT,
+    "ISSUE_CREATION_DATE" BIGINT,
+    "ISSUE_UPDATE_DATE" BIGINT,
+    "ISSUE_CLOSE_DATE" BIGINT,
+    "TAGS" CHARACTER VARYING(4000),
+    "COMPONENT_UUID" CHARACTER VARYING(50),
+    "PROJECT_UUID" CHARACTER VARYING(50),
+    "LOCATIONS" BINARY LARGE OBJECT,
+    "ISSUE_TYPE" TINYINT,
+    "FROM_HOTSPOT" BOOLEAN,
+    "QUICK_FIX_AVAILABLE" BOOLEAN
+);
+ALTER TABLE "ISSUES" ADD CONSTRAINT "PK_ISSUES" PRIMARY KEY("KEE");
+CREATE INDEX "ISSUES_ASSIGNEE" ON "ISSUES"("ASSIGNEE" NULLS FIRST);
+CREATE INDEX "ISSUES_COMPONENT_UUID" ON "ISSUES"("COMPONENT_UUID" NULLS FIRST);
+CREATE INDEX "ISSUES_CREATION_DATE" ON "ISSUES"("ISSUE_CREATION_DATE" NULLS FIRST);
+CREATE INDEX "ISSUES_PROJECT_UUID" ON "ISSUES"("PROJECT_UUID" NULLS FIRST);
+CREATE INDEX "ISSUES_RESOLUTION" ON "ISSUES"("RESOLUTION" NULLS FIRST);
+CREATE INDEX "ISSUES_UPDATED_AT" ON "ISSUES"("UPDATED_AT" NULLS FIRST);
+CREATE INDEX "ISSUES_RULE_UUID" ON "ISSUES"("RULE_UUID" NULLS FIRST);
\ No newline at end of file
index 1f0ddb37dd7c3406f2f14d20697eb1e0bd987b3d..2d85d30ab16f4538ee70231c7dcbeb4216bb9467 100644 (file)
@@ -302,18 +302,6 @@ public class IssueFieldsSetter {
     return setEffort(issue, currentEffort, context);
   }
 
-  public boolean setAttribute(DefaultIssue issue, String key, @Nullable String value, IssueChangeContext context) {
-    String oldValue = issue.attribute(key);
-    if (!Objects.equals(oldValue, value)) {
-      issue.setFieldChange(context, key, oldValue, value);
-      issue.setAttribute(key, value);
-      issue.setUpdateDate(context.date());
-      issue.setChanged(true);
-      return true;
-    }
-    return false;
-  }
-
   public boolean setTags(DefaultIssue issue, Collection<String> tags, IssueChangeContext context) {
     Set<String> newTags = RuleTagFormat.validate(tags);
 
index 28bb4ff34dff5bb1264313a11b6631b19172a947..2ab5b815ed01e5e56af093fb91be71fb8917b4bd 100644 (file)
@@ -342,37 +342,6 @@ public class IssueFieldsSetterTest {
     assertThat(issue.mustSendNotifications()).isFalse();
   }
 
-  @Test
-  public void set_new_attribute_value() {
-    boolean updated = underTest.setAttribute(issue, "JIRA", "FOO-123", context);
-    assertThat(updated).isTrue();
-    assertThat(issue.attribute("JIRA")).isEqualTo("FOO-123");
-    assertThat(issue.currentChange().diffs()).hasSize(1);
-    assertThat(issue.currentChange().get("JIRA").oldValue()).isNull();
-    assertThat(issue.currentChange().get("JIRA").newValue()).isEqualTo("FOO-123");
-    assertThat(issue.mustSendNotifications()).isFalse();
-  }
-
-  @Test
-  public void unset_attribute() {
-    issue.setAttribute("JIRA", "FOO-123");
-    boolean updated = underTest.setAttribute(issue, "JIRA", null, context);
-    assertThat(updated).isTrue();
-    assertThat(issue.attribute("JIRA")).isNull();
-    assertThat(issue.currentChange().diffs()).hasSize(1);
-    assertThat(issue.currentChange().get("JIRA").oldValue()).isEqualTo("FOO-123");
-    assertThat(issue.currentChange().get("JIRA").newValue()).isNull();
-    assertThat(issue.mustSendNotifications()).isFalse();
-  }
-
-  @Test
-  public void not_update_attribute() {
-    issue.setAttribute("JIRA", "FOO-123");
-    boolean updated = underTest.setAttribute(issue, "JIRA", "FOO-123", context);
-    assertThat(updated).isFalse();
-    assertThat(issue.mustSendNotifications()).isFalse();
-  }
-
   @Test
   public void set_gap_to_fix() {
     boolean updated = underTest.setGap(issue, 3.14, context);
index f67e112e74e8437497889e0653570b972ab6a5a4..b43eb7bc89c8acf95b4dc7cf6a55c23f46e52ec7 100644 (file)
@@ -63,7 +63,6 @@ public class IssueIteratorFactoryTest {
         .setMessage(null)
         .setLine(444)
         .setRuleUuid(rule.getUuid())
-        .setIssueAttributes("JIRA=http://jira.com")
         .setTags(List.of("tag1", "tag2", "tag3"))
         .setCreatedAt(1400000000000L)
         .setUpdatedAt(1400000000000L)
@@ -108,15 +107,12 @@ public class IssueIteratorFactoryTest {
       t -> t
         .setAssigneeUuid("uuid-of-guy1")
         .setAuthorLogin("guy2")
-        .setRuleUuid(rule.getUuid())
-        .setIssueAttributes("JIRA=http://jira.com")
         .setEffort(10L)
         .setType(1));
     IssueDto moduleIssue = dbTester.issues().insert(rule, project, module, t -> t
       .setAssigneeUuid("uuid-of-guy2")
       .setAuthorLogin("guy2")
-      .setRuleUuid(rule.getUuid())
-      .setIssueAttributes("JIRA=http://jira.com"));
+      .setRuleUuid(rule.getUuid()));
     IssueDto dirIssue = dbTester.issues().insert(rule, project, directory);
     IssueDto projectIssue = dbTester.issues().insert(rule, project, project);
 
index 8aa563d94eeb9da3dd3971b2bc0b4f27e3b542f6..6e1fac26ae296f04eeecc6f78b03cd5cd82c067c 100644 (file)
@@ -106,7 +106,6 @@ public class WebIssueStorageTest {
       .setResolution("OPEN")
       .setStatus("OPEN")
       .setSeverity("BLOCKER")
-      .setAttribute("foo", "bar")
       .addComment(comment)
       .setCreationDate(date)
       .setUpdateDate(date)
@@ -151,7 +150,6 @@ public class WebIssueStorageTest {
       .setResolution("OPEN")
       .setStatus("OPEN")
       .setSeverity("BLOCKER")
-      .setAttribute("foo", "bar")
       .setCreationDate(date)
       .setUpdateDate(date)
       .setCloseDate(date);
@@ -179,7 +177,6 @@ public class WebIssueStorageTest {
       .setResolution("FIXED")
       .setStatus("RESOLVED")
       .setSeverity("MAJOR")
-      .setAttribute("fox", "bax")
       .setCreationDate(DateUtils.addDays(date, 1))
       .setUpdateDate(DateUtils.addDays(date, 1))
       .setCloseDate(DateUtils.addDays(date, 1))
@@ -198,7 +195,6 @@ public class WebIssueStorageTest {
       .containsEntry("CHECKSUM", updated.checksum())
       .containsEntry("COMPONENT_UUID", issue.componentUuid())
       .containsEntry("EFFORT", updated.effortInMinutes())
-      .containsEntry("ISSUE_ATTRIBUTES", "fox=bax")
       .containsEntry("ISSUE_TYPE", 3L)
       .containsEntry("KEE", issue.key())
       .containsEntry("LINE", (long) updated.line())
index 6ea5ecbde85e6e4681d8dc9fc625490bf379a588..198bc25d418b4274fc4cf889d9b33ce3d6d597aa 100644 (file)
@@ -22,7 +22,6 @@ package org.sonar.core.issue;
 import com.google.common.base.Preconditions;
 import com.google.common.base.Strings;
 import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.ImmutableSet;
 import java.io.Serializable;
 import java.util.ArrayList;
@@ -75,7 +74,6 @@ public class DefaultIssue implements Issue, Trackable, org.sonar.api.ce.measure.
   private String resolution;
   private String assigneeUuid;
   private String checksum;
-  private Map<String, String> attributes = null;
   private String authorLogin = null;
   private List<DefaultIssueComment> comments = null;
   private Set<String> tags = null;
@@ -475,37 +473,23 @@ public class DefaultIssue implements Issue, Trackable, org.sonar.api.ce.measure.
     return this;
   }
 
+  /**
+   * @deprecated since 9.4, attribute was already not returning any element since 5.2
+   */
+  @Deprecated
   @Override
   @CheckForNull
   public String attribute(String key) {
-    return attributes == null ? null : attributes.get(key);
-  }
-
-  public DefaultIssue setAttribute(String key, @Nullable String value) {
-    if (attributes == null) {
-      attributes = new HashMap<>();
-    }
-    if (value == null) {
-      attributes.remove(key);
-    } else {
-      attributes.put(key, value);
-    }
-    return this;
+    return null;
   }
 
+  /**
+   * @deprecated since 9.4, attribute was already not returning any element since 5.2
+   */
+  @Deprecated
   @Override
   public Map<String, String> attributes() {
-    return attributes == null ? Collections.emptyMap() : ImmutableMap.copyOf(attributes);
-  }
-
-  public DefaultIssue setAttributes(@Nullable Map<String, String> map) {
-    if (map != null) {
-      if (attributes == null) {
-        attributes = new HashMap<>();
-      }
-      attributes.putAll(map);
-    }
-    return this;
+    return new HashMap<>();
   }
 
   @Override
index 1d0eebe493a7ae242a2702c2b659880fe0c98ffa..97797a5a4961d5d1a2fdc6435178d8cf7d67ac4f 100644 (file)
@@ -116,29 +116,6 @@ public class DefaultIssueTest {
     assertThat(issue.selectedAt()).isNull();
   }
 
-  @Test
-  public void test_attributes() {
-    assertThat(issue.attribute("foo")).isNull();
-    issue.setAttribute("foo", "bar");
-    assertThat(issue.attribute("foo")).isEqualTo("bar");
-    issue.setAttribute("foo", "newbar");
-    assertThat(issue.attribute("foo")).isEqualTo("newbar");
-    issue.setAttribute("foo", null);
-    assertThat(issue.attribute("foo")).isNull();
-  }
-
-  @Test
-  public void setAttributes_should_not_clear_existing_values() {
-    issue.setAttributes(ImmutableMap.of("1", "one"));
-    assertThat(issue.attribute("1")).isEqualTo("one");
-
-    issue.setAttributes(ImmutableMap.of("2", "two"));
-    assertThat(issue.attributes()).containsOnly(entry("1", "one"), entry("2", "two"));
-
-    issue.setAttributes(null);
-    assertThat(issue.attributes()).containsOnly(entry("1", "one"), entry("2", "two"));
-  }
-
   @Test
   public void fail_on_empty_status() {
     try {
index 692885f5f37b333a39743dfa6bd85f7ac9ab8f7d..12ce624cbf491511f67ed91dc36684e41a70bed2 100644 (file)
@@ -179,6 +179,10 @@ public interface Issue extends Serializable {
   @CheckForNull
   Date closeDate();
 
+  /**
+   * @deprecated since 9.4, attribute was already not returning any element since 5.2
+   */
+  @Deprecated
   @CheckForNull
   String attribute(String key);
 
@@ -186,6 +190,10 @@ public interface Issue extends Serializable {
    * Empty on batch side since version 5.2. Attributes are moved to server's Compute Engine. No use-case for keeping them
    * on batch side for now
    */
+  /**
+   * @deprecated since 9.4, attribute was already not returning any element since 5.2
+   */
+  @Deprecated
   Map<String, String> attributes();
 
   /**