]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-4301 Replace issues.severity column type from String to Integer
authorJulien Lancelot <julien.lancelot@gmail.com>
Tue, 21 May 2013 12:14:58 +0000 (14:14 +0200)
committerJulien Lancelot <julien.lancelot@gmail.com>
Tue, 21 May 2013 12:14:58 +0000 (14:14 +0200)
44 files changed:
plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/IssueTrackingDecorator.java
sonar-core/src/main/java/org/sonar/core/issue/db/IssueDto.java
sonar-core/src/main/java/org/sonar/core/persistence/DatabaseVersion.java
sonar-core/src/main/resources/org/sonar/core/issue/db/IssueMapper.xml
sonar-core/src/main/resources/org/sonar/core/persistence/rows-h2.sql
sonar-core/src/main/resources/org/sonar/core/persistence/schema-h2.ddl
sonar-core/src/test/java/org/sonar/core/issue/db/IssueDaoTest.java
sonar-core/src/test/java/org/sonar/core/issue/db/IssueDtoTest.java
sonar-core/src/test/java/org/sonar/core/issue/db/IssueMapperTest.java
sonar-core/src/test/resources/org/sonar/core/issue/db/ActionPlanStatsDaoTest/should_find_by_project.xml
sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_all.xml
sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_by_action_plans.xml
sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_by_assigned.xml
sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_by_component_root.xml
sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_by_date_creation.xml
sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_by_ids.xml
sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_by_key.xml
sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_by_planned.xml
sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_by_query.xml
sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_by_resolved.xml
sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_by_rules.xml
sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_issue_and_component_ids.xml
sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_open_issues.xml
sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_returned_sorted_result_by_assignee.xml
sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_returned_sorted_result_by_close_date.xml
sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_returned_sorted_result_by_creation_date.xml
sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_returned_sorted_result_by_severity.xml
sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_returned_sorted_result_by_status.xml
sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_returned_sorted_result_by_update_date.xml
sonar-core/src/test/resources/org/sonar/core/issue/db/IssueMapperTest/testInsert-result.xml
sonar-core/src/test/resources/org/sonar/core/issue/db/IssueMapperTest/testUpdate-result.xml
sonar-core/src/test/resources/org/sonar/core/issue/db/IssueMapperTest/testUpdate.xml
sonar-core/src/test/resources/org/sonar/core/issue/db/IssueStorageTest/should_insert_new_issues-result.xml
sonar-core/src/test/resources/org/sonar/core/issue/db/IssueStorageTest/should_update_issues-result.xml
sonar-core/src/test/resources/org/sonar/core/issue/db/IssueStorageTest/should_update_issues.xml
sonar-core/src/test/resources/org/sonar/core/persistence/DryRunDatabaseFactoryTest/should_create_database_with_issues.xml
sonar-core/src/test/resources/org/sonar/core/purge/PurgeCommandsTest/shouldDeleteResource.xml
sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/shouldDeleteProject.xml
sonar-plugin-api/src/main/java/org/sonar/api/issue/IssueQuery.java
sonar-plugin-api/src/test/java/org/sonar/api/issue/IssueQueryTest.java
sonar-server/src/main/webapp/WEB-INF/db/migrate/395_create_issues.rb [deleted file]
sonar-server/src/main/webapp/WEB-INF/db/migrate/396_create_issue_changes.rb [deleted file]
sonar-server/src/main/webapp/WEB-INF/db/migrate/398_create_issues.rb [new file with mode: 0644]
sonar-server/src/main/webapp/WEB-INF/db/migrate/399_create_issue_changes.rb [new file with mode: 0644]

index e45a749a33deb9636a5b37b81179a2e3d19463b0..170bf467e3c48ee2290787463b1b9f733f88aa06 100644 (file)
@@ -43,7 +43,6 @@ import org.sonar.core.issue.db.IssueDto;
 import org.sonar.core.issue.workflow.IssueWorkflow;
 
 import java.util.Collection;
-import java.util.Map;
 
 @DependedUpon(DecoratorBarriers.END_OF_ISSUES_UPDATES)
 public class IssueTrackingDecorator implements Decorator {
@@ -148,11 +147,11 @@ public class IssueTrackingDecorator implements Decorator {
       // fields to update with current values
       if (ref.isManualSeverity()) {
         issue.setManualSeverity(true);
-        issue.setSeverity(ref.getSeverity());
+        issue.setSeverity(ref.getSeverityLabel());
       } else {
         // Emulate change of severity in the current scan.
         String severity = issue.severity();
-        issue.setSeverity(ref.getSeverity());
+        issue.setSeverity(ref.getSeverityLabel());
         updater.setSeverity(issue, severity, changeContext);
       }
       Integer line = issue.line();
index de545172be55b88a41645fb5fadd77e43ec361e4..8bf64abc1a3b0ad7a21dc080999d992bc735c96b 100644 (file)
@@ -21,14 +21,18 @@ package org.sonar.core.issue.db;
 
 import com.google.common.base.Objects;
 import com.google.common.base.Preconditions;
+import com.google.common.base.Predicate;
+import com.google.common.collect.Iterables;
 import org.apache.commons.lang.builder.ToStringBuilder;
 import org.apache.commons.lang.builder.ToStringStyle;
 import org.sonar.api.rule.RuleKey;
+import org.sonar.api.rule.Severity;
 import org.sonar.api.utils.KeyValueFormat;
 import org.sonar.core.issue.DefaultIssue;
 
 import javax.annotation.CheckForNull;
 import javax.annotation.Nullable;
+
 import java.util.Date;
 
 /**
@@ -40,7 +44,7 @@ public final class IssueDto {
   private String kee;
   private Integer resourceId;
   private Integer ruleId;
-  private String severity;
+  private Integer severity;
   private boolean manualSeverity;
   private String message;
   private Integer line;
@@ -115,11 +119,11 @@ public final class IssueDto {
   }
 
   @CheckForNull
-  public String getSeverity() {
+  public Integer getSeverity() {
     return severity;
   }
 
-  public IssueDto setSeverity(@Nullable String severity) {
+  public IssueDto setSeverity(@Nullable Integer severity) {
     this.severity = severity;
     return this;
   }
@@ -288,6 +292,11 @@ public final class IssueDto {
     return componentKey;
   }
 
+  @CheckForNull
+  public String getSeverityLabel() {
+    return severity != null ? Severity.ALL.get(severity - 1) : null;
+  }
+
   /**
    * Only for unit tests
    */
@@ -310,6 +319,18 @@ public final class IssueDto {
     return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
   }
 
+  private static Integer toSeverityIndex(final String severity){
+    if (severity != null) {
+      return Iterables.indexOf(Severity.ALL, new Predicate<String>() {
+        @Override
+        public boolean apply(String currentSeverity) {
+          return currentSeverity.equals(severity);
+        }
+      }) + 1;
+    }
+    return null;
+  }
+
   public static IssueDto toDtoForInsert(DefaultIssue issue, Integer componentId, Integer ruleId, Date now) {
     return new IssueDto()
       .setKee(issue.key())
@@ -318,7 +339,7 @@ public final class IssueDto {
       .setEffortToFix(issue.effortToFix())
       .setResolution(issue.resolution())
       .setStatus(issue.status())
-      .setSeverity(issue.severity())
+      .setSeverity(toSeverityIndex(issue.severity()))
       .setChecksum(issue.getChecksum())
       .setManualSeverity(issue.manualSeverity())
       .setReporter(issue.reporter())
@@ -345,7 +366,7 @@ public final class IssueDto {
       .setEffortToFix(issue.effortToFix())
       .setResolution(issue.resolution())
       .setStatus(issue.status())
-      .setSeverity(issue.severity())
+      .setSeverity(toSeverityIndex(issue.severity()))
       .setChecksum(issue.getChecksum())
       .setManualSeverity(issue.manualSeverity())
       .setReporter(issue.reporter())
@@ -367,7 +388,7 @@ public final class IssueDto {
     issue.setMessage(message);
     issue.setEffortToFix(effortToFix);
     issue.setLine(line);
-    issue.setSeverity(severity);
+    issue.setSeverity(getSeverityLabel());
     issue.setReporter(reporter);
     issue.setAssignee(assignee);
     issue.setAttributes(KeyValueFormat.parse(Objects.firstNonNull(attributes, "")));
index aafefbd4286f0b54380d08ec038620a5aeeee5c2..39fdd04cd9867d0e002b5f4efedc714f4639676d 100644 (file)
@@ -32,7 +32,7 @@ import java.util.List;
  */
 public class DatabaseVersion implements BatchComponent, ServerComponent {
 
-  public static final int LAST_VERSION = 397;
+  public static final int LAST_VERSION = 399;
 
   public static enum Status {
     UP_TO_DATE, REQUIRES_UPGRADE, REQUIRES_DOWNGRADE, FRESH_INSTALL
index 9717a2417cfb86c8c7946ef7614b1d981086d10c..01991164893c61cfc7bb3f0422da85421d5afe54 100644 (file)
         <foreach item="key" index="index" collection="issueKeys" open="(" separator="," close=")">#{key}
         </foreach>
       </if>
-      <if test="severities != null">
+      <if test="severitiesIndexSql != null">
         and i.severity in
-        <foreach item="severity" index="index" collection="severities" open="(" separator="," close=")">#{severity}
+        <foreach item="severity" index="index" collection="severitiesIndexSql" open="(" separator="," close=")">#{severity}
         </foreach>
       </if>
       <if test="statuses != null">
index 6b3fcd5313f1c6abd64dfad2986d7e767ca0daae..2311cec80a3cd6fdcde360071dad87d9f55a4a9d 100644 (file)
@@ -159,9 +159,9 @@ INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('388');
 INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('391');
 INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('392');
 INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('394');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('395');
-INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('396');
 INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('397');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('398');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('399');
 
 INSERT INTO USERS(ID, LOGIN, NAME, EMAIL, CRYPTED_PASSWORD, SALT, CREATED_AT, UPDATED_AT, REMEMBER_TOKEN, REMEMBER_TOKEN_EXPIRES_AT) VALUES (1, 'admin', 'Administrator', '', 'a373a0e667abb2604c1fd571eb4ad47fe8cc0878', '48bc4b0d93179b5103fd3885ea9119498e9d161b', '2011-09-26 22:27:48.0', '2011-09-26 22:27:48.0', null, null);
 ALTER TABLE USERS ALTER COLUMN ID RESTART WITH 2;
index 640817337a557bed27674fca8044416974be8304..e7bcf22855a9fe8f6eaedda7b462f417c83bc73f 100644 (file)
@@ -521,7 +521,7 @@ CREATE TABLE "ISSUES" (
   "KEE" VARCHAR(50) UNIQUE NOT NULL,
   "RESOURCE_ID" INTEGER NOT NULL,
   "RULE_ID" INTEGER,
-  "SEVERITY" VARCHAR(10),
+  "SEVERITY" INTEGER,
   "MANUAL_SEVERITY" BOOLEAN NOT NULL,
   "MESSAGE" VARCHAR(4000),
   "LINE" INTEGER,
index cfb30567f2100817a94985030275c38b6687b268..3c962585f1994ec018eb131260aad53e6ef76cd1 100644 (file)
@@ -51,7 +51,7 @@ public class IssueDaoTest extends AbstractDaoTestCase {
     assertThat(issue.getId()).isEqualTo(100L);
     assertThat(issue.getResourceId()).isEqualTo(401);
     assertThat(issue.getRuleId()).isEqualTo(500);
-    assertThat(issue.getSeverity()).isEqualTo("BLOCKER");
+    assertThat(issue.getSeverity()).isEqualTo(5);
     assertThat(issue.isManualSeverity()).isFalse();
     assertThat(issue.getMessage()).isNull();
     assertThat(issue.getLine()).isEqualTo(200);
@@ -227,9 +227,9 @@ public class IssueDaoTest extends AbstractDaoTestCase {
     IssueQuery query = IssueQuery.builder().sort(IssueQuery.Sort.SEVERITY).asc(true).build();
     List<IssueDto> results = newArrayList(dao.select(query));
     assertThat(results).hasSize(3);
-    assertThat(results.get(0).getSeverity()).isEqualTo("BLOCKER");
-    assertThat(results.get(1).getSeverity()).isEqualTo("MAJOR");
-    assertThat(results.get(2).getSeverity()).isEqualTo("MINOR");
+    assertThat(results.get(0).getSeverityLabel()).isEqualTo("MINOR");
+    assertThat(results.get(1).getSeverityLabel()).isEqualTo("MAJOR");
+    assertThat(results.get(2).getSeverityLabel()).isEqualTo("BLOCKER");
   }
 
   @Test
index 9598b8c796dc4f48997bf63191908522c1baea7e..551dc0926e3e4dabcd6bec30516f9445ceaa50d5 100644 (file)
@@ -63,7 +63,7 @@ public class IssueDtoTest {
         .setResolution(Issue.RESOLUTION_FALSE_POSITIVE)
         .setEffortToFix(15.0)
         .setLine(6)
-        .setSeverity("BLOCKER")
+        .setSeverity(5)
         .setMessage("message")
         .setManualSeverity(true)
         .setReporter("arthur")
index d606a87080d1fbad9e9aba8aaddc2635d2a3cd6e..7767c139710494fa6baeaefa1d27e4d0be0d8b11 100644 (file)
@@ -46,7 +46,7 @@ public class IssueMapperTest extends AbstractDaoTestCase {
     dto.setEffortToFix(3.14);
     dto.setResolution("FIXED");
     dto.setStatus("RESOLVED");
-    dto.setSeverity("BLOCKER");
+    dto.setSeverity(5);
     dto.setReporter("emmerik");
     dto.setAuthorLogin("morgan");
     dto.setAssignee("karadoc");
@@ -79,7 +79,7 @@ public class IssueMapperTest extends AbstractDaoTestCase {
     dto.setEffortToFix(3.14);
     dto.setResolution("FIXED");
     dto.setStatus("RESOLVED");
-    dto.setSeverity("BLOCKER");
+    dto.setSeverity(5);
     dto.setReporter("emmerik");
     dto.setAuthorLogin("morgan");
     dto.setAssignee("karadoc");
index f960ecd1b62d88ec7e6599f601438062a58279f7..af6e601bb1806b7fc6b5d42456769e031d45b2a2 100644 (file)
@@ -8,7 +8,7 @@
       kee="ABCDE"
       resource_id="400"
       rule_id="500"
-      severity="BLOCKER"
+      severity="5"
       manual_severity="[false]"
       message="[null]"
       line="200"
@@ -32,7 +32,7 @@
       kee="ABCDF"
       resource_id="400"
       rule_id="500"
-      severity="BLOCKER"
+      severity="5"
       manual_severity="[false]"
       message="[null]"
       line="200"
@@ -56,7 +56,7 @@
       kee="ABCDG"
       resource_id="400"
       rule_id="500"
-      severity="BLOCKER"
+      severity="5"
       manual_severity="[false]"
       message="[null]"
       line="200"
index 3d7bd96af2126c6adb78f0a22ea32d4875e5168e..fb1aedd72222ed89de3730ff0ec5477eb4bf3670 100644 (file)
@@ -6,7 +6,7 @@
       kee="ABCDE-1"
       resource_id="401"
       rule_id="500"
-      severity="BLOCKER"
+      severity="5"
       manual_severity="[false]"
       message="[null]"
       line="200"
@@ -30,7 +30,7 @@
       kee="ABCDE-2"
       resource_id="401"
       rule_id="500"
-      severity="BLOCKER"
+      severity="5"
       manual_severity="[false]"
       message="[null]"
       line="200"
@@ -56,7 +56,7 @@
       kee="ABCDE-3"
       resource_id="401"
       rule_id="501"
-      severity="BLOCKER"
+      severity="5"
       manual_severity="[false]"
       message="[null]"
       line="200"
index 5655372b58e3d0e895c558d6176e3a62947fa8b5..de78e71414d1143a4adb475363be0fa3581ed5c7 100644 (file)
@@ -6,7 +6,7 @@
       resource_id="401"
       rule_id="500"
       action_plan_key="ABC"
-      severity="BLOCKER"
+      severity="5"
       manual_severity="[false]"
       message="[null]"
       line="200"
@@ -31,7 +31,7 @@
       resource_id="401"
       rule_id="500"
       action_plan_key="ABC"
-      severity="BLOCKER"
+      severity="5"
       manual_severity="[false]"
       message="[null]"
       line="200"
@@ -57,7 +57,7 @@
       resource_id="401"
       rule_id="501"
       action_plan_key="DEF"
-      severity="BLOCKER"
+      severity="5"
       manual_severity="[false]"
       message="[null]"
       line="200"
index f25c1c9e8ea5d1b0af0a0524b1bc8063e5c193b7..1d3d7943d7eba19896415680b8610f49b63faa12 100644 (file)
@@ -6,7 +6,7 @@
       kee="ABCDE-1"
       resource_id="401"
       rule_id="500"
-      severity="BLOCKER"
+      severity="5"
       manual_severity="[false]"
       message="[null]"
       line="200"
@@ -30,7 +30,7 @@
       kee="ABCDE-2"
       resource_id="401"
       rule_id="500"
-      severity="BLOCKER"
+      severity="5"
       manual_severity="[false]"
       message="[null]"
       line="200"
@@ -56,7 +56,7 @@
       kee="ABCDE-3"
       resource_id="401"
       rule_id="501"
-      severity="BLOCKER"
+      severity="5"
       manual_severity="[false]"
       message="[null]"
       line="200"
index 34f07c20209acd50515bb2e7de9df21aac765a37..2319088e7f06637802cc484c44b724d1769a9b68 100644 (file)
@@ -5,7 +5,7 @@
       kee="100"
       resource_id="401"
       rule_id="500"
-      severity="BLOCKER"
+      severity="5"
       manual_severity="[false]"
       message="[null]"
       line="200"
@@ -29,7 +29,7 @@
       kee="101"
       resource_id="402"
       rule_id="501"
-      severity="MAJOR"
+      severity="3"
       manual_severity="[false]"
       message="[null]"
       line="120"
index 9b6f20c96ca8aee11be82f76da302db2cc6f3fe2..c1fddd480d35974d11a2be6d8814de6a7db9b7ad 100644 (file)
@@ -5,7 +5,7 @@
       kee="ABCDE-1"
       resource_id="401"
       rule_id="500"
-      severity="BLOCKER"
+      severity="5"
       manual_severity="[false]"
       message="[null]"
       line="200"
@@ -29,7 +29,7 @@
       kee="ABCDE-2"
       resource_id="401"
       rule_id="500"
-      severity="BLOCKER"
+      severity="5"
       manual_severity="[false]"
       message="[null]"
       line="200"
index 3d6ad15c5a062f9afb02b7e23ecdf4f1c11b022b..d6f85f325c4e951f71ac000033f195c6fd1eaad4 100644 (file)
@@ -6,7 +6,7 @@
       kee="ABCDE-1"
       resource_id="401"
       rule_id="500"
-      severity="BLOCKER"
+      severity="5"
       manual_severity="[false]"
       message="[null]"
       line="200"
@@ -30,7 +30,7 @@
       kee="ABCDE-2"
       resource_id="401"
       rule_id="500"
-      severity="BLOCKER"
+      severity="5"
       manual_severity="[false]"
       message="[null]"
       line="200"
@@ -56,7 +56,7 @@
       kee="ABCDE"
       resource_id="401"
       rule_id="501"
-      severity="BLOCKER"
+      severity="5"
       manual_severity="[false]"
       message="[null]"
       line="200"
index d01f5342d8780aa620dacb210e8c6c35b582c454..88ca9ebd96062a30f690d4b569bee35f1e420aad 100644 (file)
@@ -5,7 +5,7 @@
       kee="ABCDE"
       resource_id="401"
       rule_id="500"
-      severity="BLOCKER"
+      severity="5"
       manual_severity="[false]"
       message="[null]"
       line="200"
index ded6b072043db4a42483ba8b61dc857feae94511..9aa1641068bdeb8062c59ee6c2895b81a7ce226b 100644 (file)
@@ -6,7 +6,7 @@
       resource_id="401"
       rule_id="500"
       action_plan_key="ABC"
-      severity="BLOCKER"
+      severity="5"
       manual_severity="[false]"
       message="[null]"
       line="200"
@@ -31,7 +31,7 @@
       resource_id="401"
       rule_id="500"
       action_plan_key="ABC"
-      severity="BLOCKER"
+      severity="5"
       manual_severity="[false]"
       message="[null]"
       line="200"
@@ -57,7 +57,7 @@
       resource_id="401"
       rule_id="501"
       action_plan_key="[null]"
-      severity="BLOCKER"
+      severity="5"
       manual_severity="[false]"
       message="[null]"
       line="200"
index 816742b954b30158e92d625dd54237a607886d79..557be9b7ba50f20f9ce22e9ed9dd38d60bad40b3 100644 (file)
@@ -5,7 +5,7 @@
       kee="ABCDE"
       resource_id="401"
       rule_id="500"
-      severity="BLOCKER"
+      severity="5"
       manual_severity="[false]"
       message="[null]"
       line="200"
index 371d3da3f4f22174fa51c90655ca9d8dd3baffa6..886fb14e175d6f3a32d8f9c44d7a2c4c610af902 100644 (file)
@@ -5,7 +5,7 @@
       kee="ABCDE-1"
       resource_id="401"
       rule_id="500"
-      severity="BLOCKER"
+      severity="5"
       manual_severity="[false]"
       message="[null]"
       line="200"
@@ -29,7 +29,7 @@
       kee="ABCDE-2"
       resource_id="401"
       rule_id="500"
-      severity="BLOCKER"
+      severity="5"
       manual_severity="[false]"
       message="[null]"
       line="200"
@@ -53,7 +53,7 @@
       kee="ABCDE-3"
       resource_id="401"
       rule_id="501"
-      severity="BLOCKER"
+      severity="5"
       manual_severity="[false]"
       message="[null]"
       line="200"
index d2af6661a9eb7f25faa21faece12c4cbf5d92fd3..d20560f08118650fa01959b74e5590a19a78cb84 100644 (file)
@@ -6,7 +6,7 @@
       kee="ABCDE-1"
       resource_id="401"
       rule_id="500"
-      severity="BLOCKER"
+      severity="5"
       manual_severity="[false]"
       message="[null]"
       line="200"
@@ -30,7 +30,7 @@
       kee="ABCDE-2"
       resource_id="401"
       rule_id="500"
-      severity="BLOCKER"
+      severity="5"
       manual_severity="[false]"
       message="[null]"
       line="200"
@@ -56,7 +56,7 @@
       kee="ABCDE-3"
       resource_id="401"
       rule_id="501"
-      severity="BLOCKER"
+      severity="5"
       manual_severity="[false]"
       message="[null]"
       line="200"
index 3d7bd96af2126c6adb78f0a22ea32d4875e5168e..fb1aedd72222ed89de3730ff0ec5477eb4bf3670 100644 (file)
@@ -6,7 +6,7 @@
       kee="ABCDE-1"
       resource_id="401"
       rule_id="500"
-      severity="BLOCKER"
+      severity="5"
       manual_severity="[false]"
       message="[null]"
       line="200"
@@ -30,7 +30,7 @@
       kee="ABCDE-2"
       resource_id="401"
       rule_id="500"
-      severity="BLOCKER"
+      severity="5"
       manual_severity="[false]"
       message="[null]"
       line="200"
@@ -56,7 +56,7 @@
       kee="ABCDE-3"
       resource_id="401"
       rule_id="501"
-      severity="BLOCKER"
+      severity="5"
       manual_severity="[false]"
       message="[null]"
       line="200"
index 12f7036120e18dde09e90cc2991f787a1089eb57..8b3a9f44ca382e8b9809a50b5caab5a2f76fc608 100644 (file)
@@ -5,7 +5,7 @@
       kee="100"
       resource_id="401"
       rule_id="500"
-      severity="BLOCKER"
+      severity="5"
       manual_severity="[false]"
       message="[null]"
       line="200"
@@ -29,7 +29,7 @@
       kee="101"
       resource_id="402"
       rule_id="501"
-      severity="MAJOR"
+      severity="3"
       manual_severity="[false]"
       message="[null]"
       line="120"
@@ -53,7 +53,7 @@
       kee="102"
       resource_id="402"
       rule_id="501"
-      severity="MAJOR"
+      severity="3"
       manual_severity="[false]"
       message="[null]"
       line="120"
index 41a97ef98b80e809108e87d5eb075f0c7d698851..2f902a85565c709552fca9329a3411decdfd2fae 100644 (file)
@@ -6,7 +6,7 @@
       kee="ABCDE-1"
       resource_id="401"
       rule_id="500"
-      severity="BLOCKER"
+      severity="5"
       manual_severity="[false]"
       message="[null]"
       line="200"
@@ -30,7 +30,7 @@
       kee="ABCDE-2"
       resource_id="401"
       rule_id="500"
-      severity="BLOCKER"
+      severity="5"
       manual_severity="[false]"
       message="[null]"
       line="200"
@@ -56,7 +56,7 @@
       kee="ABCDE-3"
       resource_id="401"
       rule_id="501"
-      severity="BLOCKER"
+      severity="5"
       manual_severity="[false]"
       message="[null]"
       line="200"
index b27051ff2074aeb6bd789fe1235406523fab6311..9339d6e437ed8daa413b698ccf8f8210d4c080c4 100644 (file)
@@ -6,7 +6,7 @@
       kee="ABCDE-1"
       resource_id="401"
       rule_id="500"
-      severity="BLOCKER"
+      severity="5"
       manual_severity="[false]"
       message="[null]"
       line="200"
@@ -30,7 +30,7 @@
       kee="ABCDE-2"
       resource_id="401"
       rule_id="500"
-      severity="BLOCKER"
+      severity="5"
       manual_severity="[false]"
       message="[null]"
       line="200"
@@ -56,7 +56,7 @@
       kee="ABCDE-3"
       resource_id="401"
       rule_id="501"
-      severity="BLOCKER"
+      severity="5"
       manual_severity="[false]"
       message="[null]"
       line="200"
index d84b71fa09be5116d390484f358c69ddafbcb66d..b4c6ba44d29d4df01ed3ce66f6daebff9cff6cc4 100644 (file)
@@ -5,7 +5,7 @@
       kee="ABCDE-1"
       resource_id="401"
       rule_id="500"
-      severity="BLOCKER"
+      severity="5"
       manual_severity="[false]"
       message="[null]"
       line="200"
@@ -29,7 +29,7 @@
       kee="ABCDE-2"
       resource_id="401"
       rule_id="500"
-      severity="BLOCKER"
+      severity="5"
       manual_severity="[false]"
       message="[null]"
       line="200"
@@ -53,7 +53,7 @@
       kee="ABCDE-3"
       resource_id="401"
       rule_id="501"
-      severity="BLOCKER"
+      severity="5"
       manual_severity="[false]"
       message="[null]"
       line="200"
index 9dae4080973c05fa371c73ce8ea59d39142c2f57..e5ffc2e5fda7292df6612d34985b4dd0e0cf7218 100644 (file)
@@ -5,7 +5,7 @@
       kee="ABCDE-1"
       resource_id="401"
       rule_id="500"
-      severity="MINOR"
+      severity="2"
       manual_severity="[false]"
       message="[null]"
       line="200"
@@ -29,7 +29,7 @@
       kee="ABCDE-2"
       resource_id="401"
       rule_id="500"
-      severity="BLOCKER"
+      severity="5"
       manual_severity="[false]"
       message="[null]"
       line="200"
@@ -53,7 +53,7 @@
       kee="ABCDE-3"
       resource_id="401"
       rule_id="501"
-      severity="MAJOR"
+      severity="3"
       manual_severity="[false]"
       message="[null]"
       line="200"
index b510a5c447ae311f2cb6ffbe3afcf55443eb64c3..4e12d924be8d8f06afe8d18dd28bddd5057c2952 100644 (file)
@@ -6,7 +6,7 @@
       kee="ABCDE-1"
       resource_id="401"
       rule_id="500"
-      severity="BLOCKER"
+      severity="5"
       manual_severity="[false]"
       message="[null]"
       line="200"
@@ -30,7 +30,7 @@
       kee="ABCDE-2"
       resource_id="401"
       rule_id="500"
-      severity="BLOCKER"
+      severity="5"
       manual_severity="[false]"
       message="[null]"
       line="200"
@@ -56,7 +56,7 @@
       kee="ABCDE-3"
       resource_id="401"
       rule_id="501"
-      severity="BLOCKER"
+      severity="5"
       manual_severity="[false]"
       message="[null]"
       line="200"
index 769bae1454d1a5e9f88f21787640d6fc52f9dd66..a74da66a8c88109b4501aa480bff4f4208c2b66f 100644 (file)
@@ -5,7 +5,7 @@
       kee="ABCDE-1"
       resource_id="401"
       rule_id="500"
-      severity="BLOCKER"
+      severity="5"
       manual_severity="[false]"
       message="[null]"
       line="200"
@@ -29,7 +29,7 @@
       kee="ABCDE-2"
       resource_id="401"
       rule_id="500"
-      severity="BLOCKER"
+      severity="5"
       manual_severity="[false]"
       message="[null]"
       line="200"
@@ -53,7 +53,7 @@
       kee="ABCDE-3"
       resource_id="401"
       rule_id="501"
-      severity="BLOCKER"
+      severity="5"
       manual_severity="[false]"
       message="[null]"
       line="200"
index 69e5160f9622b9cceee9f498c2dc1664ab2831bf..e32f7d9f30c0a3d745f813e08035393c16d4ab3c 100644 (file)
@@ -4,7 +4,7 @@
       kee="ABCDE"
       resource_id="123"
       rule_id="200"
-      severity="BLOCKER"
+      severity="5"
       manual_severity="[false]"
       message="the message"
       line="500"
index 57bc88451eaf3697cd46786105d209c6c65eb2cb..7bcccd58b05a1674086951da3e26b6726ef3a2f2 100644 (file)
@@ -23,7 +23,7 @@
       kee="ABCDE"
       resource_id="123"
       rule_id="200"
-      severity="BLOCKER"
+      severity="5"
       manual_severity="[false]"
       message="the message"
       line="500"
index 06ee1af1b5061a27444999dbc1c7938c5492dedd..9e13008d3db7c398fdfcd34c770cb1e4927fdd0a 100644 (file)
@@ -23,7 +23,7 @@
       kee="ABCDE"
       resource_id="123"
       rule_id="200"
-      severity="INFO"
+      severity="1"
       manual_severity="[false]"
       message="old"
       line="[null]"
index 97ca9b21656101c57cdaa484e17d5ce3cd7eb2e7..0a10ae36591908c41fbc1a2e96dfa88cdabd5719 100644 (file)
@@ -1,5 +1,5 @@
 <dataset>
-  <issues id="1" kee="ABCDE" resolution="OPEN" status="OPEN" severity="BLOCKER" manual_severity="[false]"
+  <issues id="1" kee="ABCDE" resolution="OPEN" status="OPEN" severity="5" manual_severity="[false]"
       assignee="[null]"
       author_login="[null]"
       checksum="[null]"
index 862d14f2b750073c3d2ec15a7d60f60c0bfee6d6..17f7def9bf32291fa4a6c64fc5f8d4c5795d274d 100644 (file)
@@ -3,7 +3,7 @@
           kee="ABCDE"
           resolution="FIXED"
           status="RESOLVED"
-          severity="BLOCKER"
+          severity="5"
           manual_severity="[false]"
           assignee="loic"
           author_login="simon"
index 4d8e2449c578896472a29d26cc4013debb724ecd..709dc7ccf89a194868f40b2e69939d8ec0640c41 100644 (file)
@@ -3,7 +3,7 @@
           kee="ABCDE"
           resolution="OPEN"
           status="OPEN"
-          severity="BLOCKER"
+          severity="5"
           manual_severity="[false]"
           assignee="loic"
           author_login="simon"
index 5bf87b320ac82995aafdf0e7bb925fb5db73d7e2..3a331c758145eae14d7429cb9655341a7c39164d 100644 (file)
@@ -23,7 +23,7 @@
       kee="100"
       resource_id="400"
       rule_id="500"
-      severity="BLOCKER"
+      severity="5"
       manual_severity="[false]"
       message="[null]"
       line="200"
@@ -47,7 +47,7 @@
       kee="101"
       resource_id="401"
       rule_id="501"
-      severity="MAJOR"
+      severity="3"
       manual_severity="[false]"
       message="[null]"
       line="120"
index e8a31f031de75e9fe68aa7d68b27e02bd8ca4ee9..22d0be9cb39efe8f2672537b28d14c273acf7c51 100644 (file)
@@ -24,7 +24,7 @@
 
   <review_comments id="1" created_at="[null]" updated_at="[null]" review_id="1" user_id="1223" review_text="abc"/>
 
-  <issues id="1" kee="ABCDE" resource_id="1" status="CLOSED" resolution="[null]" line="200" severity="BLOCKER"
+  <issues id="1" kee="ABCDE" resource_id="1" status="CLOSED" resolution="[null]" line="200" severity="5"
           reporter="perceval" assignee="arthur" rule_id="500"
           manual_severity="[false]"
           message="[null]"
index 5c57259dab6ac1a810d961110c79ad0bea54f6c3..887df9002784460c05a4f58859f9c818ce387b00 100644 (file)
@@ -31,7 +31,7 @@
 
   <review_comments id="1" created_at="[null]" updated_at="[null]" review_id="2" user_id="1223" review_text="abc"/>
 
-  <issues id="1" kee="ABCDE" resource_id="1" status="CLOSED" resolution="[null]" line="200" severity="BLOCKER"
+  <issues id="1" kee="ABCDE" resource_id="1" status="CLOSED" resolution="[null]" line="200" severity="5"
           reporter="perceval" assignee="arthur" rule_id="500"
           manual_severity="[false]"
           message="[null]"
@@ -43,7 +43,7 @@
           issue_close_date="2013-04-16"
       />
 
-  <issues id="2" kee="ABCDF" resource_id="1" status="CLOSED" resolution="[null]" line="200" severity="BLOCKER"
+  <issues id="2" kee="ABCDF" resource_id="1" status="CLOSED" resolution="[null]" line="200" severity="5"
           reporter="perceval" assignee="arthur" rule_id="500"
           manual_severity="[false]"
           message="[null]"
index 4a74dedf0fbafe058f9fdeb6a561adf17336701e..946b71bdbb2ec2a0ccfbfd520110d1e89f343857 100644 (file)
  */
 package org.sonar.api.issue;
 
+import com.google.common.base.Function;
 import com.google.common.base.Preconditions;
+import com.google.common.base.Predicate;
+import com.google.common.collect.Iterables;
 import org.apache.commons.lang.builder.ReflectionToStringBuilder;
 import org.sonar.api.rule.RuleKey;
+import org.sonar.api.rule.Severity;
 
 import javax.annotation.CheckForNull;
 import javax.annotation.Nullable;
@@ -29,6 +33,8 @@ import javax.annotation.Nullable;
 import java.util.Collection;
 import java.util.Date;
 
+import static com.google.common.collect.Lists.newArrayList;
+
 /**
  * @since 3.6
  */
@@ -68,6 +74,9 @@ public class IssueQuery {
   // index of selected page. Start with 1.
   private final int pageIndex;
 
+  // for internal use in MyBatis
+  protected final Collection<Integer> severitiesIndexSql;
+
   private IssueQuery(Builder builder) {
     this.issueKeys = builder.issueKeys;
     this.severities = builder.severities;
@@ -89,6 +98,8 @@ public class IssueQuery {
     this.pageSize = builder.pageSize;
     this.pageIndex = builder.pageIndex;
     this.requiredRole = builder.requiredRole;
+
+    this.severitiesIndexSql = severitiesIndexSql(severities);
   }
 
   public Collection<String> issueKeys() {
@@ -181,6 +192,23 @@ public class IssueQuery {
     return new Builder();
   }
 
+  private Collection<Integer> severitiesIndexSql(@Nullable Collection<String> severities) {
+    if (severities != null) {
+      return newArrayList(Iterables.transform(severities, new Function<String, Integer>() {
+        @Override
+        public Integer apply(final String currentSeverity) {
+          return Iterables.indexOf(Severity.ALL, new Predicate<String>() {
+            @Override
+            public boolean apply(String severity) {
+              return severity.equals(currentSeverity);
+            }
+          }) + 1;
+        };
+      }));
+    }
+    return null;
+  }
+
   public static class Builder {
     private Collection<String> issueKeys;
     private Collection<String> severities;
index fb972c40ceed92a21610c0421a735f1c03f51e7e..938c5ff56f9b1770d8c057332c613797e771f234 100644 (file)
@@ -71,6 +71,7 @@ public class IssueQueryTest {
     assertThat(query.pageSize()).isEqualTo(10);
     assertThat(query.pageIndex()).isEqualTo(2);
     assertThat(query.requiredRole()).isEqualTo(UserRole.CODEVIEWER);
+    assertThat(query.severitiesIndexSql).containsOnly(5);
   }
 
   @Test
diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/395_create_issues.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/395_create_issues.rb
deleted file mode 100644 (file)
index 2733202..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-#
-# Sonar, entreprise quality control tool.
-# Copyright (C) 2008-2013 SonarSource
-# mailto:contact AT sonarsource DOT com
-#
-# SonarQube 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.
-#
-# SonarQube 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.
-#
-
-#
-# Sonar 3.6
-#
-class CreateIssues < ActiveRecord::Migration
-
-  def self.up
-    create_table :issues do |t|
-      t.column :kee,                  :string,    :null => false,   :limit => 50
-      t.column :resource_id,          :integer,   :null => false
-      t.column :rule_id,              :integer,   :null => true
-      t.column :severity,                                        :string,        :null => true,          :limit => 10
-      t.column :manual_severity,      :boolean,   :null => false
-      t.column :message,              :string,    :null => true,    :limit => 4000
-      t.column :line,                 :integer,   :null => true
-      t.column :effort_to_fix,        :decimal,   :null => true,    :precision => 30,   :scale => 20
-      t.column :status,               :string ,   :null => true,    :limit => 20
-      t.column :resolution,           :string ,   :null => true,    :limit => 20
-      t.column :checksum,             :string ,   :null => true,    :limit => 1000
-      t.column :reporter,             :string,    :null => true,         :limit => 40
-      t.column :assignee,             :string,    :null => true,         :limit => 40
-      t.column :author_login,         :string,    :null => true,    :limit => 100
-      t.column :action_plan_key,      :string,    :null => true,    :limit => 50
-      t.column :attributes,           :string,    :null => true,    :limit => 4000
-
-      # functional dates
-      t.column :issue_creation_date,  :datetime,  :null => true
-      t.column :issue_close_date,     :datetime,  :null => true
-      t.column :issue_update_date,    :datetime,  :null => true
-
-      # technical dates
-      t.column :created_at,           :datetime,  :null => true
-      t.column :updated_at,           :datetime,  :null => true
-    end
-
-    add_index :issues,  :kee,                 :name => 'issues_kee',         :unique => true
-    add_index :issues,  :resource_id,         :name => 'issues_resource_id'
-    add_index :issues,  :rule_id,             :name => 'issues_rule_id'
-    add_index :issues,  :severity,            :name => 'issues_severity'
-    add_index :issues,  :status,              :name => 'issues_status'
-    add_index :issues,  :assignee,            :name => 'issues_assignee'
-    add_index :issues,  :action_plan_key,     :name => 'issues_action_plan_key'
-    add_index :issues,  :issue_creation_date, :name => 'issues_creation_date'
-  end
-
-end
-
diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/396_create_issue_changes.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/396_create_issue_changes.rb
deleted file mode 100644 (file)
index 016380c..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-#
-# Sonar, entreprise quality control tool.
-# Copyright (C) 2008-2013 SonarSource
-# mailto:contact AT sonarsource DOT com
-#
-# SonarQube 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.
-#
-# SonarQube 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.
-#
-
-#
-# Sonar 3.6
-#
-class CreateIssueChanges < ActiveRecord::Migration
-
-  def self.up
-    create_table :issue_changes do |t|
-      t.column :kee,                :string,    :null => true,    :limit => 50
-      t.column :issue_key,          :string,    :null => false,   :limit => 50
-      t.column :user_login,         :string,    :null => true,   :limit => 40
-      t.column :change_type,                           :string,          :null => true,          :limit => 20
-      t.column :change_data,        :text,      :null => true
-      t.column :created_at,         :datetime,  :null => true
-      t.column :updated_at,         :datetime,  :null => true
-    end
-
-    add_index :issue_changes,  :kee,         :name => 'issue_changes_kee'
-    add_index :issue_changes,  :issue_key,   :name => 'issue_changes_issue_key'
-  end
-
-end
-
diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/398_create_issues.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/398_create_issues.rb
new file mode 100644 (file)
index 0000000..7a26290
--- /dev/null
@@ -0,0 +1,66 @@
+#
+# Sonar, entreprise quality control tool.
+# Copyright (C) 2008-2013 SonarSource
+# mailto:contact AT sonarsource DOT com
+#
+# SonarQube 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.
+#
+# SonarQube 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.
+#
+
+#
+# Sonar 3.6
+#
+class CreateIssues < ActiveRecord::Migration
+
+  def self.up
+    create_table :issues do |t|
+      t.column :kee,                  :string,    :null => false,   :limit => 50
+      t.column :resource_id,          :integer,   :null => false
+      t.column :rule_id,              :integer,   :null => true
+      t.column :severity,                                        :integer,       :null => true
+      t.column :manual_severity,      :boolean,   :null => false
+      t.column :message,              :string,    :null => true,    :limit => 4000
+      t.column :line,                 :integer,   :null => true
+      t.column :effort_to_fix,        :decimal,   :null => true,    :precision => 30,   :scale => 20
+      t.column :status,               :string ,   :null => true,    :limit => 20
+      t.column :resolution,           :string ,   :null => true,    :limit => 20
+      t.column :checksum,             :string ,   :null => true,    :limit => 1000
+      t.column :reporter,             :string,    :null => true,         :limit => 40
+      t.column :assignee,             :string,    :null => true,         :limit => 40
+      t.column :author_login,         :string,    :null => true,    :limit => 100
+      t.column :action_plan_key,      :string,    :null => true,    :limit => 50
+      t.column :attributes,           :string,    :null => true,    :limit => 4000
+
+      # functional dates
+      t.column :issue_creation_date,  :datetime,  :null => true
+      t.column :issue_close_date,     :datetime,  :null => true
+      t.column :issue_update_date,    :datetime,  :null => true
+
+      # technical dates
+      t.column :created_at,           :datetime,  :null => true
+      t.column :updated_at,           :datetime,  :null => true
+    end
+
+    add_index :issues,  :kee,                 :name => 'issues_kee',         :unique => true
+    add_index :issues,  :resource_id,         :name => 'issues_resource_id'
+    add_index :issues,  :rule_id,             :name => 'issues_rule_id'
+    add_index :issues,  :severity,            :name => 'issues_severity'
+    add_index :issues,  :status,              :name => 'issues_status'
+    add_index :issues,  :assignee,            :name => 'issues_assignee'
+    add_index :issues,  :action_plan_key,     :name => 'issues_action_plan_key'
+    add_index :issues,  :issue_creation_date, :name => 'issues_creation_date'
+  end
+
+end
+
diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/399_create_issue_changes.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/399_create_issue_changes.rb
new file mode 100644 (file)
index 0000000..016380c
--- /dev/null
@@ -0,0 +1,42 @@
+#
+# Sonar, entreprise quality control tool.
+# Copyright (C) 2008-2013 SonarSource
+# mailto:contact AT sonarsource DOT com
+#
+# SonarQube 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.
+#
+# SonarQube 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.
+#
+
+#
+# Sonar 3.6
+#
+class CreateIssueChanges < ActiveRecord::Migration
+
+  def self.up
+    create_table :issue_changes do |t|
+      t.column :kee,                :string,    :null => true,    :limit => 50
+      t.column :issue_key,          :string,    :null => false,   :limit => 50
+      t.column :user_login,         :string,    :null => true,   :limit => 40
+      t.column :change_type,                           :string,          :null => true,          :limit => 20
+      t.column :change_data,        :text,      :null => true
+      t.column :created_at,         :datetime,  :null => true
+      t.column :updated_at,         :datetime,  :null => true
+    end
+
+    add_index :issue_changes,  :kee,         :name => 'issue_changes_kee'
+    add_index :issue_changes,  :issue_key,   :name => 'issue_changes_issue_key'
+  end
+
+end
+