]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-7330 Update date columns of rules and active_rules
authorJulien Lancelot <julien.lancelot@sonarsource.com>
Fri, 26 Feb 2016 15:27:24 +0000 (16:27 +0100)
committerJulien Lancelot <julien.lancelot@sonarsource.com>
Mon, 29 Feb 2016 12:26:54 +0000 (13:26 +0100)
61 files changed:
server/sonar-server/src/main/java/org/sonar/server/debt/DebtModelBackup.java
server/sonar-server/src/main/java/org/sonar/server/qualityprofile/RuleActivator.java
server/sonar-server/src/main/java/org/sonar/server/qualityprofile/index/ActiveRuleResultSetIterator.java
server/sonar-server/src/main/java/org/sonar/server/rule/DefaultRuleFinder.java
server/sonar-server/src/main/java/org/sonar/server/rule/RegisterRules.java
server/sonar-server/src/main/java/org/sonar/server/rule/RuleCreator.java
server/sonar-server/src/main/java/org/sonar/server/rule/RuleUpdater.java
server/sonar-server/src/main/java/org/sonar/server/rule/index/RuleResultSetIterator.java
server/sonar-server/src/main/java/org/sonar/server/rule/ws/RuleMapper.java
server/sonar-server/src/main/java/org/sonar/server/startup/ClearRulesOverloadedDebt.java
server/sonar-server/src/test/java/org/sonar/server/debt/DebtModelBackupTest.java
server/sonar-server/src/test/java/org/sonar/server/qualityprofile/RuleActivatorMediumTest.java
server/sonar-server/src/test/java/org/sonar/server/qualityprofile/index/ActiveRuleIndexerTest.java
server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/InheritanceActionMediumTest.java
server/sonar-server/src/test/java/org/sonar/server/rule/RegisterRulesMediumTest.java
server/sonar-server/src/test/java/org/sonar/server/rule/RegisterRulesTest.java
server/sonar-server/src/test/java/org/sonar/server/rule/RuleCreatorMediumTest.java
server/sonar-server/src/test/java/org/sonar/server/rule/index/RuleIndexerTest.java
server/sonar-server/src/test/java/org/sonar/server/rule/ws/SearchActionMediumTest.java
server/sonar-server/src/test/java/org/sonar/server/startup/ClearRulesOverloadedDebtTest.java
server/sonar-server/src/test/resources/org/sonar/server/computation/step/PersistIssuesStepTest/insert_new_issue.xml
server/sonar-server/src/test/resources/org/sonar/server/computation/step/PersistIssuesStepTest/shared.xml
server/sonar-server/src/test/resources/org/sonar/server/platform/BackendCleanupMediumTest/shared.xml
server/sonar-server/src/test/resources/org/sonar/server/qualityprofile/index/ActiveRuleIndexerTest/index.xml
server/sonar-server/src/test/resources/org/sonar/server/qualityprofile/index/ActiveRuleResultSetIteratorTest/active_rule_with_inherited_inheritance.xml
server/sonar-server/src/test/resources/org/sonar/server/qualityprofile/index/ActiveRuleResultSetIteratorTest/active_rule_with_overrides_inheritance.xml
server/sonar-server/src/test/resources/org/sonar/server/qualityprofile/index/ActiveRuleResultSetIteratorTest/one_active_rule.xml
server/sonar-server/src/test/resources/org/sonar/server/qualityprofile/index/ActiveRuleResultSetIteratorTest/shared.xml
server/sonar-server/src/test/resources/org/sonar/server/rule/index/RuleIndexerTest/index.xml
server/sonar-server/src/test/resources/org/sonar/server/rule/index/RuleIndexerTest/removed_rule.xml
server/sonar-server/src/test/resources/org/sonar/server/rule/index/RuleResultSetIteratorTest/custom_rule.xml
server/sonar-server/src/test/resources/org/sonar/server/rule/index/RuleResultSetIteratorTest/one_rule.xml
server/sonar-server/src/test/resources/org/sonar/server/rule/index/RuleResultSetIteratorTest/removed_rule.xml
server/sonar-server/src/test/resources/org/sonar/server/rule/index/RuleResultSetIteratorTest/shared.xml
server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1108_drop_rules_date_columns.rb [new file with mode: 0644]
server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1109_rename_rules_long_dates.rb [new file with mode: 0644]
server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1110_drop_active_rules_date_columns.rb [new file with mode: 0644]
server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1111_rename_active_rules_long_dates.rb [new file with mode: 0644]
sonar-db/src/main/java/org/sonar/db/qualityprofile/ActiveRuleDto.java
sonar-db/src/main/java/org/sonar/db/rule/RuleDto.java
sonar-db/src/main/java/org/sonar/db/version/DatabaseVersion.java
sonar-db/src/main/java/org/sonar/db/version/MigrationStepModule.java
sonar-db/src/main/java/org/sonar/db/version/v55/DropActiveRulesDateColumns.java [new file with mode: 0644]
sonar-db/src/main/java/org/sonar/db/version/v55/DropRulesDateColumns.java [new file with mode: 0644]
sonar-db/src/main/resources/org/sonar/db/qualityprofile/ActiveRuleMapper.xml
sonar-db/src/main/resources/org/sonar/db/rule/RuleMapper.xml
sonar-db/src/main/resources/org/sonar/db/version/rows-h2.sql
sonar-db/src/main/resources/org/sonar/db/version/schema-h2.ddl
sonar-db/src/test/java/org/sonar/db/rule/RuleDaoTest.java
sonar-db/src/test/java/org/sonar/db/version/MigrationStepModuleTest.java
sonar-db/src/test/java/org/sonar/db/version/v55/DropActiveRulesDateColumnsTest.java [new file with mode: 0644]
sonar-db/src/test/java/org/sonar/db/version/v55/DropRulesDateColumnsTest.java [new file with mode: 0644]
sonar-db/src/test/resources/org/sonar/db/rule/RuleDaoTest/insert_parameter-result.xml
sonar-db/src/test/resources/org/sonar/db/rule/RuleDaoTest/insert_parameter.xml
sonar-db/src/test/resources/org/sonar/db/rule/RuleDaoTest/selectEnabledAndNonManual.xml
sonar-db/src/test/resources/org/sonar/db/rule/RuleDaoTest/selectNonManual.xml
sonar-db/src/test/resources/org/sonar/db/rule/RuleDaoTest/select_parameters_by_rule_key.xml
sonar-db/src/test/resources/org/sonar/db/rule/RuleDaoTest/shared.xml
sonar-db/src/test/resources/org/sonar/db/rule/RuleDaoTest/update.xml
sonar-db/src/test/resources/org/sonar/db/rule/RuleDaoTest/update_parameter-result.xml
sonar-db/src/test/resources/org/sonar/db/rule/RuleDaoTest/update_parameter.xml

index 1f308137e0a0fc05ad69f3f1f480f5e1a6aed95f..997fb701a8fda6bf621aff539ceace2d7cdda005 100644 (file)
@@ -158,7 +158,7 @@ public class DebtModelBackup {
       rule.setRemediationFunction(null);
       rule.setRemediationCoefficient(null);
       rule.setRemediationOffset(null);
-      rule.setUpdatedAtInMs(updateDate.getTime());
+      rule.setUpdatedAt(updateDate.getTime());
       dbClient.ruleDao().update(session, rule);
     }
   }
@@ -205,7 +205,7 @@ public class DebtModelBackup {
         ruleDebt != null ? ruleDebt.function() : null,
         ruleDebt != null ? ruleDebt.coefficient() : null,
         ruleDebt != null ? ruleDebt.offset() : null, session);
-      rule.setUpdatedAtInMs(updateDate.getTime());
+      rule.setUpdatedAt(updateDate.getTime());
       ruleDebts.remove(ruleDebt);
     }
 
index a278611705fb337135ed573c6d9f2cf9b1479e26..6c2b8422e0184391fafdcaf20a0daf3c740018cb 100644 (file)
@@ -257,8 +257,8 @@ public class RuleActivator {
     if (inheritance != null) {
       activeRule.setInheritance(inheritance.name());
     }
-    activeRule.setUpdatedAtInMs(system2.now());
-    activeRule.setCreatedAtInMs(system2.now());
+    activeRule.setUpdatedAt(system2.now());
+    activeRule.setCreatedAt(system2.now());
     dao.insert(dbSession, activeRule);
     for (Map.Entry<String, String> param : change.getParameters().entrySet()) {
       if (param.getValue() != null) {
@@ -282,7 +282,7 @@ public class RuleActivator {
       if (inheritance != null) {
         activeRule.setInheritance(inheritance.name());
       }
-      activeRule.setUpdatedAtInMs(system2.now());
+      activeRule.setUpdatedAt(system2.now());
       dao.update(dbSession, activeRule);
 
       for (Map.Entry<String, String> param : change.getParameters().entrySet()) {
@@ -506,7 +506,7 @@ public class RuleActivator {
           changes.addAll(deactivate(dbSession, activeRule.getKey(), true));
         } else if (ActiveRuleDto.OVERRIDES.equals(activeRule.getInheritance())) {
           activeRule.setInheritance(null);
-          activeRule.setUpdatedAtInMs(system2.now());
+          activeRule.setUpdatedAt(system2.now());
           db.activeRuleDao().update(dbSession, activeRule);
           changes.add(ActiveRuleChange.createFor(ActiveRuleChange.Type.UPDATED, activeRule.getKey()).setInheritance(null));
         }
index 1b262701eb96e219921ed5b8cbad485b5e69f82c..5b5e944a84c14966a60135c806e05689e7b48d7a 100644 (file)
@@ -44,8 +44,8 @@ public class ActiveRuleResultSetIterator extends ResultSetIterator<ActiveRuleDoc
     "r.plugin_name",
     "qp.kee",
     "profile_parent.kee",
-    "a.created_at_ms",
-    "a.updated_at_ms"
+    "a.created_at",
+    "a.updated_at"
   };
 
   private static final String SQL_ALL = "SELECT " + StringUtils.join(FIELDS, ",") + " FROM active_rules a " +
@@ -53,7 +53,7 @@ public class ActiveRuleResultSetIterator extends ResultSetIterator<ActiveRuleDoc
     "INNER JOIN rules r ON r.id = a.rule_id " +
     "LEFT JOIN rules_profiles profile_parent ON profile_parent.kee=qp.parent_kee ";
 
-  private static final String SQL_AFTER_DATE = SQL_ALL + " WHERE a.updated_at_ms>?";
+  private static final String SQL_AFTER_DATE = SQL_ALL + " WHERE a.updated_at>?";
 
   private ActiveRuleResultSetIterator(PreparedStatement stmt) throws SQLException {
     super(stmt);
index d6aaa74bcfc2006fe6f185a5607dcd1c2fa70b59..91bf2feba743dc39b4f8a287dfa7375d5d22a4ab 100644 (file)
@@ -175,8 +175,8 @@ public class DefaultRuleFinder implements RuleFinder {
       .setKey(rule.getRuleKey())
       .setConfigKey(rule.getConfigKey())
       .setIsTemplate(rule.isTemplate())
-      .setCreatedAt(new Date(rule.getCreatedAtInMs()))
-      .setUpdatedAt(new Date(rule.getUpdatedAtInMs()))
+      .setCreatedAt(new Date(rule.getCreatedAt()))
+      .setUpdatedAt(new Date(rule.getUpdatedAt()))
       .setRepositoryKey(rule.getRepositoryKey())
       .setSeverity(severity != null ? RulePriority.valueOf(severity) : null)
       .setStatus(rule.getStatus().name())
index 03f4b64f31bad9edf2c694373d74f23b83c54177..291e6fe2916997d64f1d4cd7039ee441d8a1042c 100644 (file)
@@ -171,8 +171,8 @@ public class RegisterRules implements Startable {
       .setStatus(ruleDef.status())
       .setEffortToFixDescription(ruleDef.effortToFixDescription())
       .setSystemTags(ruleDef.tags())
-      .setCreatedAtInMs(system2.now())
-      .setUpdatedAtInMs(system2.now());
+      .setCreatedAt(system2.now())
+      .setUpdatedAt(system2.now());
     if (ruleDef.htmlDescription() != null) {
       ruleDto.setDescription(ruleDef.htmlDescription());
       ruleDto.setDescriptionFormat(Format.HTML);
@@ -453,7 +453,7 @@ public class RegisterRules implements Startable {
   }
 
   private void update(DbSession session, RuleDto rule){
-    rule.setUpdatedAtInMs(system2.now());
+    rule.setUpdatedAt(system2.now());
     dbClient.ruleDao().update(session, rule);
   }
 }
index 1d0dacd9488db933e4c4ca38ed219f088eb30ab2..e5ad2a656e8fe31699c12caee1a65b9f45faf160 100644 (file)
@@ -215,8 +215,8 @@ public class RuleCreator {
       .setEffortToFixDescription(templateRuleDto.getEffortToFixDescription())
       .setTags(templateRuleDto.getTags())
       .setSystemTags(templateRuleDto.getSystemTags())
-      .setCreatedAtInMs(system2.now())
-      .setUpdatedAtInMs(system2.now());
+      .setCreatedAt(system2.now())
+      .setUpdatedAt(system2.now());
     dbClient.ruleDao().insert(dbSession, ruleDto);
 
     for (RuleParamDto templateRuleParamDto : dbClient.ruleDao().selectRuleParamsByRuleKey(dbSession, templateRuleDto.getKey())) {
@@ -242,8 +242,8 @@ public class RuleCreator {
       .setDescriptionFormat(Format.MARKDOWN)
       .setSeverity(newRule.severity())
       .setStatus(RuleStatus.READY)
-      .setCreatedAtInMs(system2.now())
-      .setUpdatedAtInMs(system2.now());
+      .setCreatedAt(system2.now())
+      .setUpdatedAt(system2.now());
     dbClient.ruleDao().insert(dbSession, ruleDto);
     return ruleKey;
   }
@@ -254,7 +254,7 @@ public class RuleCreator {
         throw new ReactivationException(String.format("A removed rule with the key '%s' already exists", ruleDto.getKey().rule()), ruleDto.getKey());
       } else {
         ruleDto.setStatus(RuleStatus.READY)
-          .setUpdatedAtInMs(system2.now());
+          .setUpdatedAt(system2.now());
         dbClient.ruleDao().update(dbSession, ruleDto);
       }
     } else {
index 0ee0dd0d4a5b63e2ee72da1c4e24777e1fa62670..38a58b16d6ad96163cce2735bfbca378ee0c2e67 100644 (file)
@@ -306,7 +306,7 @@ public class RuleUpdater {
   }
 
   private void update(DbSession session, RuleDto rule) {
-    rule.setUpdatedAtInMs(system.now());
+    rule.setUpdatedAt(system.now());
     dbClient.ruleDao().update(session, rule);
   }
 
index cf223abe9f5b4eab23e44358686b0813126ca3ad..0dbcdfddc5178f9fa8a1b3b5e7a79a56b5e48793 100644 (file)
@@ -61,14 +61,14 @@ public class RuleResultSetIterator extends ResultSetIterator<RuleDoc> {
     "t.plugin_name",
     "r.plugin_config_key",
     "r.language",
-    "r.created_at_ms",
-    "r.updated_at_ms",
+    "r.created_at",
+    "r.updated_at",
   };
 
   private static final String SQL_ALL = "SELECT " + StringUtils.join(FIELDS, ",") + " FROM rules r " +
     "LEFT OUTER JOIN rules t ON t.id=r.template_id";
 
-  private static final String SQL_AFTER_DATE = SQL_ALL + " WHERE r.updated_at_ms>?";
+  private static final String SQL_AFTER_DATE = SQL_ALL + " WHERE r.updated_at>?";
 
   private static final Splitter TAGS_SPLITTER = Splitter.on(',').trimResults().omitEmptyStrings();
 
index 9b01137e1342e9244167af8e4548b8fec88f097d..bbb6cbf112a5211d84c45d552fafcb060febb78d 100644 (file)
@@ -171,7 +171,7 @@ public class RuleMapper {
 
   private static void setCreatedAt(Rules.Rule.Builder ruleResponse, RuleDto ruleDto, Set<String> fieldsToReturn) {
     if (shouldReturnField(fieldsToReturn, RuleNormalizer.RuleField.CREATED_AT)) {
-      ruleResponse.setCreatedAt(formatDateTime(ruleDto.getCreatedAtInMs()));
+      ruleResponse.setCreatedAt(formatDateTime(ruleDto.getCreatedAt()));
     }
   }
 
index 49119d2f80fc032d99bf46ff0a5a0e262e733f43..ea1913020e6fbdd5612dc4ca5725d184d060133c 100644 (file)
@@ -85,7 +85,7 @@ public class ClearRulesOverloadedDebt implements Startable {
         rule.setRemediationFunction(null);
         rule.setRemediationCoefficient(null);
         rule.setRemediationOffset(null);
-        rule.setUpdatedAtInMs(system2.now());
+        rule.setUpdatedAt(system2.now());
         dbClient.ruleDao().update(session, rule);
         countClearedRules++;
       }
index 68b6c1d78d72b4545b5d951c51b28430ed4f4b81..5219db120d3d5000f9293bd24f5b54bc4eb65eee 100644 (file)
@@ -257,12 +257,12 @@ public class DebtModelBackupTest {
     assertThat(rule.getDefaultRemediationFunction()).isEqualTo("LINEAR_OFFSET");
     assertThat(rule.getDefaultRemediationCoefficient()).isEqualTo("4h");
     assertThat(rule.getDefaultRemediationOffset()).isEqualTo("20min");
-    assertThat(rule.getUpdatedAtInMs()).isEqualTo(now.getTime());
+    assertThat(rule.getUpdatedAt()).isEqualTo(now.getTime());
 
     assertThat(rule.getRemediationFunction()).isNull();
     assertThat(rule.getRemediationCoefficient()).isNull();
     assertThat(rule.getRemediationOffset()).isNull();
-    assertThat(rule.getUpdatedAtInMs()).isEqualTo(now.getTime());
+    assertThat(rule.getUpdatedAt()).isEqualTo(now.getTime());
   }
 
   @Test
@@ -299,7 +299,7 @@ public class DebtModelBackupTest {
     assertThat(rule.getDefaultRemediationFunction()).isNull();
     assertThat(rule.getDefaultRemediationCoefficient()).isNull();
     assertThat(rule.getDefaultRemediationOffset()).isNull();
-    assertThat(rule.getUpdatedAtInMs()).isEqualTo(now.getTime());
+    assertThat(rule.getUpdatedAt()).isEqualTo(now.getTime());
   }
 
   @Test
@@ -343,12 +343,12 @@ public class DebtModelBackupTest {
     assertThat(rule.getDefaultRemediationFunction()).isEqualTo("LINEAR_OFFSET");
     assertThat(rule.getDefaultRemediationCoefficient()).isEqualTo("4h");
     assertThat(rule.getDefaultRemediationOffset()).isEqualTo("20min");
-    assertThat(rule.getUpdatedAtInMs()).isEqualTo(now.getTime());
+    assertThat(rule.getUpdatedAt()).isEqualTo(now.getTime());
 
     assertThat(rule.getRemediationFunction()).isNull();
     assertThat(rule.getRemediationCoefficient()).isNull();
     assertThat(rule.getRemediationOffset()).isNull();
-    assertThat(rule.getUpdatedAtInMs()).isEqualTo(now.getTime());
+    assertThat(rule.getUpdatedAt()).isEqualTo(now.getTime());
   }
 
   @Test
index 5f213e685ef2a28d198400a1a701c808612a7141..409e5a9191b07ea2d41b9c648acc97daa9be7600 100644 (file)
@@ -1095,8 +1095,8 @@ public class RuleActivatorMediumTest {
         assertThat(activeRuleDto.getSeverityString()).isEqualTo(expectedSeverity);
         assertThat(activeRuleDto.getInheritance()).isEqualTo(expectedInheritance);
         // Dates should be set
-        assertThat(activeRuleDto.getCreatedAtInMs()).isNotNull();
-        assertThat(activeRuleDto.getUpdatedAtInMs()).isNotNull();
+        assertThat(activeRuleDto.getCreatedAt()).isNotNull();
+        assertThat(activeRuleDto.getUpdatedAt()).isNotNull();
 
         List<ActiveRuleParamDto> paramDtos = db.activeRuleDao().selectParamsByActiveRuleKey(dbSession, activeRuleDto.getKey());
         assertThat(paramDtos).hasSize(expectedParams.size());
index cfcf852ebf4b46f744e3104ca0c8959eb5517216..45f38494334601ca2736662b75c7f91cc1100199 100644 (file)
@@ -157,7 +157,7 @@ public class ActiveRuleIndexerTest {
     QualityProfileDto profile = QualityProfileDto.createFor("qp").setLanguage("xoo").setName("profile");
     dbTester.getDbClient().qualityProfileDao().insert(dbTester.getSession(), profile);
     ActiveRuleDto activeRule = ActiveRuleDto.createFor(profile, rule).setSeverity(Severity.BLOCKER)
-      .setCreatedAtInMs(yesterday).setUpdatedAtInMs(yesterday);
+      .setCreatedAt(yesterday).setUpdatedAt(yesterday);
     dbTester.getDbClient().activeRuleDao().insert(dbTester.getSession(), activeRule);
     dbTester.getSession().commit();
 
@@ -169,7 +169,7 @@ public class ActiveRuleIndexerTest {
     RuleDto rule2 = RuleTesting.newDto(RULE_KEY_2);
     dbTester.getDbClient().ruleDao().insert(dbTester.getSession(), rule2);
     ActiveRuleDto activeRule2 = ActiveRuleDto.createFor(profile, rule2).setSeverity(Severity.CRITICAL)
-      .setCreatedAtInMs(now).setUpdatedAtInMs(now);
+      .setCreatedAt(now).setUpdatedAt(now);
     dbTester.getDbClient().activeRuleDao().insert(dbTester.getSession(), activeRule2);
     dbTester.getSession().commit();
 
index 19e445b36d8683ab4586c68097e3e7b76f50cd96..3e741a5ec51f4a2264a98abdec45299656e6fcea 100644 (file)
@@ -146,8 +146,8 @@ public class InheritanceActionMediumTest {
       .setLanguage(lang)
       .setSeverity(Severity.BLOCKER)
       .setStatus(RuleStatus.READY)
-      .setUpdatedAtInMs(now)
-      .setCreatedAtInMs(now);
+      .setUpdatedAt(now)
+      .setCreatedAt(now);
     db.ruleDao().insert(session, rule);
     return rule;
   }
@@ -156,8 +156,8 @@ public class InheritanceActionMediumTest {
     long now = new Date().getTime();
     ActiveRuleDto activeRule = ActiveRuleDto.createFor(profile, rule)
       .setSeverity(rule.getSeverityString())
-      .setUpdatedAtInMs(now)
-      .setCreatedAtInMs(now);
+      .setUpdatedAt(now)
+      .setCreatedAt(now);
     db.activeRuleDao().insert(session, activeRule);
     return activeRule;
   }
index 0648192121a529d0987d2fcc15b1902db1828117..bc2cdff1e47f6da87773d01c24fa04d4e6f080e6 100644 (file)
@@ -324,13 +324,13 @@ public class RegisterRulesMediumTest {
       .setStatus(RuleStatus.READY)
       .setParameters(ImmutableMap.of("format", "txt")));
 
-    Long updatedAt = ruleDao.selectOrFailByKey(dbSession, customRuleKey).getUpdatedAtInMs();
+    Long updatedAt = ruleDao.selectOrFailByKey(dbSession, customRuleKey).getUpdatedAt();
 
     register(rules);
 
     // Verify custom rule has been restore from the template
     RuleDto customRuleReloaded = ruleDao.selectOrFailByKey(dbSession, customRuleKey);
-    assertThat(customRuleReloaded.getUpdatedAtInMs()).isEqualTo(updatedAt);
+    assertThat(customRuleReloaded.getUpdatedAt()).isEqualTo(updatedAt);
   }
 
   @Test
index ae72e14747fd2348e1fc5a07e78744737da1e9dd..b5a617d1b91d7ec1b7e5392a7e90c8ac36ef01f7 100644 (file)
@@ -104,8 +104,8 @@ public class RegisterRulesTest {
     assertThat(rule1.getSystemTags()).containsOnly("tag1", "tag2", "tag3");
     assertThat(rule1.getConfigKey()).isEqualTo("config1");
     assertThat(rule1.getStatus()).isEqualTo(RuleStatus.BETA);
-    assertThat(rule1.getCreatedAtInMs()).isEqualTo(DATE1.getTime());
-    assertThat(rule1.getUpdatedAtInMs()).isEqualTo(DATE1.getTime());
+    assertThat(rule1.getCreatedAt()).isEqualTo(DATE1.getTime());
+    assertThat(rule1.getUpdatedAt()).isEqualTo(DATE1.getTime());
     assertThat(rule1.getDefaultRemediationFunction()).isEqualTo(DebtRemediationFunction.Type.LINEAR_OFFSET.name());
     assertThat(rule1.getDefaultRemediationCoefficient()).isEqualTo("5d");
     assertThat(rule1.getDefaultRemediationOffset()).isEqualTo("10h");
@@ -148,8 +148,8 @@ public class RegisterRulesTest {
     assertThat(rule1.getNoteData()).isEqualTo("user *note*");
     assertThat(rule1.getNoteUserLogin()).isEqualTo("marius");
     assertThat(rule1.getStatus()).isEqualTo(RuleStatus.READY);
-    assertThat(rule1.getCreatedAtInMs()).isEqualTo(DATE1.getTime());
-    assertThat(rule1.getUpdatedAtInMs()).isEqualTo(DATE2.getTime());
+    assertThat(rule1.getCreatedAt()).isEqualTo(DATE1.getTime());
+    assertThat(rule1.getUpdatedAt()).isEqualTo(DATE2.getTime());
     // TODO check remediation function
 
     List<RuleParamDto> params = dbClient.ruleDao().selectRuleParamsByRuleKey(dbTester.getSession(), RULE_KEY1);
@@ -161,7 +161,7 @@ public class RegisterRulesTest {
     // rule2 has been removed -> status set to REMOVED but db row is not deleted
     RuleDto rule2 = dbClient.ruleDao().selectOrFailByKey(dbTester.getSession(), RULE_KEY2);
     assertThat(rule2.getStatus()).isEqualTo(RuleStatus.REMOVED);
-    assertThat(rule2.getUpdatedAtInMs()).isEqualTo(DATE2.getTime());
+    assertThat(rule2.getUpdatedAt()).isEqualTo(DATE2.getTime());
 
     // rule3 has been created
     RuleDto rule3 = dbClient.ruleDao().selectOrFailByKey(dbTester.getSession(), RULE_KEY3);
@@ -273,8 +273,8 @@ public class RegisterRulesTest {
     execute(new FakeRepositoryV1());
 
     RuleDto rule1 = dbClient.ruleDao().selectOrFailByKey(dbTester.getSession(), RULE_KEY1);
-    assertThat(rule1.getCreatedAtInMs()).isEqualTo(DATE1.getTime());
-    assertThat(rule1.getUpdatedAtInMs()).isEqualTo(DATE1.getTime());
+    assertThat(rule1.getCreatedAt()).isEqualTo(DATE1.getTime());
+    assertThat(rule1.getUpdatedAt()).isEqualTo(DATE1.getTime());
   }
 
   @Test
@@ -306,7 +306,7 @@ public class RegisterRulesTest {
     // -> rule2 is still removed, but not update at DATE3
     rule2 = dbClient.ruleDao().selectOrFailByKey(dbTester.getSession(), RULE_KEY2);
     assertThat(rule2.getStatus()).isEqualTo(RuleStatus.REMOVED);
-    assertThat(rule2.getUpdatedAtInMs()).isEqualTo(DATE2.getTime());
+    assertThat(rule2.getUpdatedAt()).isEqualTo(DATE2.getTime());
 
     assertThat(ruleIndex.search(new RuleQuery(), new SearchOptions()).getIds()).containsOnly(RULE_KEY1, RULE_KEY3);
   }
index 086f4b2939724eeab55577adf11e9652a588f2bc..950423434b4afd0623a5f60b33449972a0a8f03a 100644 (file)
@@ -688,8 +688,8 @@ public class RuleCreatorMediumTest {
       .setEffortToFixDescription("desc")
       .setTags(Sets.newHashSet("usertag1", "usertag2"))
       .setSystemTags(Sets.newHashSet("tag1", "tag4"))
-      .setCreatedAtInMs(new Date().getTime())
-      .setUpdatedAtInMs(new Date().getTime());
+      .setCreatedAt(new Date().getTime())
+      .setUpdatedAt(new Date().getTime());
     dao.insert(dbSession, templateRule);
     RuleParamDto ruleParamDto = RuleParamDto.createFor(templateRule).setName("regex").setType("STRING").setDescription("Reg ex").setDefaultValue(".*");
     dao.insertRuleParam(dbSession, templateRule, ruleParamDto);
@@ -707,8 +707,8 @@ public class RuleCreatorMediumTest {
       .setDefaultRemediationCoefficient("1h")
       .setDefaultRemediationOffset("5min")
       .setEffortToFixDescription("desc")
-      .setCreatedAtInMs(new Date().getTime())
-      .setUpdatedAtInMs(new Date().getTime());
+      .setCreatedAt(new Date().getTime())
+      .setUpdatedAt(new Date().getTime());
     dao.insert(dbSession, templateRule);
     RuleParamDto ruleParamDto = RuleParamDto.createFor(templateRule)
       .setName("myIntegers").setType("INTEGER,multiple=true,values=1;2;3").setDescription("My Integers").setDefaultValue("1");
@@ -727,8 +727,8 @@ public class RuleCreatorMediumTest {
       .setDefaultRemediationCoefficient("1h")
       .setDefaultRemediationOffset("5min")
       .setEffortToFixDescription("desc")
-      .setCreatedAtInMs(new Date().getTime())
-      .setUpdatedAtInMs(new Date().getTime());
+      .setCreatedAt(new Date().getTime())
+      .setUpdatedAt(new Date().getTime());
     dao.insert(dbSession, templateRule);
     RuleParamDto ruleParam1Dto = RuleParamDto.createFor(templateRule)
       .setName("first").setType("INTEGER").setDescription("First integer").setDefaultValue("0");
index d77445a6f4fbe9bf5ce718837c219763351957a8..a3c8a206f88045b6bef297aab63ca8d0e9556dd2 100644 (file)
@@ -84,14 +84,14 @@ public class RuleIndexerTest {
     // Create and Index rule
     RuleDto ruleDto = RuleTesting.newDto(RuleKey.of("xoo", "S001"))
       .setStatus(RuleStatus.READY)
-      .setUpdatedAtInMs(1000L);
+      .setUpdatedAt(1000L);
     dbTester.getDbClient().ruleDao().insert(dbTester.getSession(), ruleDto);
     dbTester.getSession().commit();
     indexer.index();
 
     // Remove rule
     ruleDto.setStatus(RuleStatus.REMOVED);
-    ruleDto.setUpdatedAtInMs(2000L);
+    ruleDto.setUpdatedAt(2000L);
     dbTester.getDbClient().ruleDao().update(dbTester.getSession(), ruleDto);
     dbTester.getSession().commit();
     indexer.index();
index 5e7eb7b719d219d6380675d35280ef1327709efc..79bd12c564b8619ece7b88aadb324a2b6d38f34e 100644 (file)
@@ -547,11 +547,11 @@ public class SearchActionMediumTest {
   public void available_since() throws Exception {
     Date since = new Date();
     ruleDao.insert(dbSession, RuleTesting.newXooX1()
-      .setUpdatedAtInMs(since.getTime())
-      .setCreatedAtInMs(since.getTime()));
+      .setUpdatedAt(since.getTime())
+      .setCreatedAt(since.getTime()));
     ruleDao.insert(dbSession, RuleTesting.newXooX2()
-      .setUpdatedAtInMs(since.getTime())
-      .setCreatedAtInMs(since.getTime()));
+      .setUpdatedAt(since.getTime())
+      .setCreatedAt(since.getTime()));
 
     dbSession.commit();
     dbSession.clearCache();
index 684c0fd06c11c1de3d68da911e5d1d6ff519ca44..f6bc97fef8f9dca0b66b37e9971aeab39456cdc6 100644 (file)
@@ -90,12 +90,12 @@ public class ClearRulesOverloadedDebtTest {
   @Test
   public void not_update_rule_debt_not_overridden() throws Exception {
     RuleDto rule = insertRuleDto(RULE_KEY_1, null, null, null, null);
-    long updateAt = rule.getUpdatedAtInMs();
+    long updateAt = rule.getUpdatedAt();
 
     underTest.start();
 
     RuleDto reloaded = ruleDao.selectOrFailByKey(dbSession, RULE_KEY_1);
-    assertThat(reloaded.getUpdatedAtInMs()).isEqualTo(updateAt);
+    assertThat(reloaded.getUpdatedAt()).isEqualTo(updateAt);
     verifyRuleHasNotOverriddenDebt(RULE_KEY_1);
 
     verifyTaskRegistered();
@@ -106,12 +106,12 @@ public class ClearRulesOverloadedDebtTest {
   public void not_update_rule_debt_when_sqale_is_installed() throws Exception {
     insertSqaleProperty();
     RuleDto rule = insertRuleDto(RULE_KEY_1, SUB_CHARACTERISTIC_ID, "LINEAR", null, "1d");
-    long updateAt = rule.getUpdatedAtInMs();
+    long updateAt = rule.getUpdatedAt();
 
     underTest.start();
 
     RuleDto reloaded = ruleDao.selectOrFailByKey(dbSession, RULE_KEY_1);
-    assertThat(reloaded.getUpdatedAtInMs()).isEqualTo(updateAt);
+    assertThat(reloaded.getUpdatedAt()).isEqualTo(updateAt);
 
     verifyTaskRegistered();
     verifyEmptyLog();
index 9f3a7f46ea4f69e83e380286f723655020f7aa1b..b3228c223b1543fdfc5745a8793f08f9791ba29a 100644 (file)
@@ -9,7 +9,7 @@
          remediation_offset="5min" default_remediation_offset="10h"
          effort_to_fix_description="[null]" description_format="MARKDOWN"
          tags="[null]" system_tags="[null]"
-         created_at="2013-12-16" updated_at="2013-12-16"
+         created_at="1500000000000" updated_at="1500000000000"
       />
 
 </dataset>
index a06f7a729e0279984a804c4e6f88335759488601..69125c85d937ae2b8958b6eb11a70c00371760c8 100644 (file)
@@ -9,7 +9,7 @@
          remediation_offset="5min" default_remediation_offset="10h"
          effort_to_fix_description="[null]" description_format="MARKDOWN"
          tags="[null]" system_tags="[null]"
-         created_at="2013-12-16" updated_at="2013-12-16"
+         created_at="1500000000000" updated_at="1500000000000"
       />
 
   <issues
index b8d1435944446462b08db3fcfe13c0a946475eeb..dd71fc74cee446e1c4a77333ee824dbaa64b428e 100644 (file)
@@ -16,8 +16,7 @@
          remediation_coeff="1h" default_remediation_coeff="5d"
          remediation_offset="5min" default_remediation_offset="10h"
          effort_to_fix_description="squid.S115.effortToFix" description_format="MARKDOWN"
-         created_at="2013-12-16" updated_at="2013-12-16"
-         created_at_ms="150000" updated_at_ms="150000"
+         created_at="150000" updated_at="150000"
   />
 
   <properties id="1" prop_key="sonar.profile.java" text_value="Sonar Way" resource_id="1" user_id="[null]"/>
index a2f2f9503f7f5daaf012fc6baf0a19f1ab58974f..d2a59d2049cb1db3e701e4c70db7b9f4850a644d 100644 (file)
@@ -4,10 +4,10 @@
          plugin_config_key="S1" description_format="HTML" description="S001 desc" language="xoo"
          priority="4" status="READY" is_template="[false]" template_id="[null]"
          tags="bug,performance" system_tags="cwe"
-         created_at_ms="1500000000000" updated_at_ms="1600000000000"/>
+         created_at="1500000000000" updated_at="1600000000000"/>
 
   <rules_profiles id="100" name="Sonar Way" kee="sonar-way" language="xoo" parent_kee="[null]" is_default="[false]"/>
 
   <active_rules id="1" profile_id="100" rule_id="10" failure_level="3" inheritance="[null]"
-                created_at_ms="1500000000000" updated_at_ms="1600000000000"/>
+                created_at="1500000000000" updated_at="1600000000000"/>
 </dataset>
index 32aecb5f149d57897c567b53e01c5eef5fb1f74a..3a0f5ddb92d43af15f9075f5416f4d80b35fb7bc 100644 (file)
@@ -4,17 +4,17 @@
          plugin_config_key="S1" description_format="HTML" description="S001 desc" language="xoo"
          priority="4" status="READY" is_template="[false]" template_id="[null]"
          tags="bug,performance" system_tags="cwe"
-         created_at_ms="1500000000000" updated_at_ms="1600000000000"/>
+         created_at="1500000000000" updated_at="1600000000000"/>
 
   <rules_profiles id="1" name="Parent" kee="parent" language="xoo" parent_kee="[null]" is_default="[false]"/>
 
   <rules_profiles id="2" name="Child" kee="child" language="xoo" parent_kee="parent" is_default="[false]"/>
 
   <active_rules id="1" profile_id="2" rule_id="10" failure_level="4" inheritance="INHERITED"
-                created_at_ms="1500000000000" updated_at_ms="1600000000000"/>
+                created_at="1500000000000" updated_at="1600000000000"/>
 
   <!-- Parent of Active rule 1 -->
   <active_rules id="2" profile_id="1" rule_id="10" failure_level="0" inheritance="[null]"
-                created_at_ms="1500000000000" updated_at_ms="1600000000000"/>
+                created_at="1500000000000" updated_at="1600000000000"/>
 
 </dataset>
index a20b455e9ef081afe93e188a58073ba2e23a3dae..b5a820cd45919b5d653cb9adf8f6de8211919244 100644 (file)
@@ -4,17 +4,17 @@
          plugin_config_key="S1" description_format="HTML" description="S001 desc" language="xoo"
          priority="4" status="READY" is_template="[false]" template_id="[null]"
          tags="bug,performance" system_tags="cwe"
-         created_at_ms="1500000000000" updated_at_ms="1600000000000"/>
+         created_at="1500000000000" updated_at="1600000000000"/>
 
   <rules_profiles id="1" name="Parent" kee="parent" language="xoo" parent_kee="[null]" is_default="[false]"/>
 
   <rules_profiles id="2" name="Child" kee="child" language="xoo" parent_kee="parent" is_default="[false]"/>
 
   <active_rules id="1" profile_id="2" rule_id="10" failure_level="2" inheritance="OVERRIDES"
-                created_at_ms="1500000000000" updated_at_ms="1600000000000"/>
+                created_at="1500000000000" updated_at="1600000000000"/>
 
   <!-- Parent of Active rule 1 -->
   <active_rules id="2" profile_id="1" rule_id="10" failure_level="0" inheritance="[null]"
-                created_at_ms="1500000000000" updated_at_ms="1600000000000"/>
+                created_at="1500000000000" updated_at="1600000000000"/>
 
 </dataset>
index a2f2f9503f7f5daaf012fc6baf0a19f1ab58974f..d2a59d2049cb1db3e701e4c70db7b9f4850a644d 100644 (file)
@@ -4,10 +4,10 @@
          plugin_config_key="S1" description_format="HTML" description="S001 desc" language="xoo"
          priority="4" status="READY" is_template="[false]" template_id="[null]"
          tags="bug,performance" system_tags="cwe"
-         created_at_ms="1500000000000" updated_at_ms="1600000000000"/>
+         created_at="1500000000000" updated_at="1600000000000"/>
 
   <rules_profiles id="100" name="Sonar Way" kee="sonar-way" language="xoo" parent_kee="[null]" is_default="[false]"/>
 
   <active_rules id="1" profile_id="100" rule_id="10" failure_level="3" inheritance="[null]"
-                created_at_ms="1500000000000" updated_at_ms="1600000000000"/>
+                created_at="1500000000000" updated_at="1600000000000"/>
 </dataset>
index bda9c4da2160b01100e4e1adecb51931bf549fcc..3e6062ccc972a3e3b0885bc3c105fffac4b8cb66 100644 (file)
@@ -6,8 +6,7 @@
          priority="4" status="READY"
          is_template="[false]" template_id="[null]"
          tags="bug,performance" system_tags="cwe"
-         created_at="2014-05-10" updated_at="2014-05-11"
-         created_at_ms="1500000000000" updated_at_ms="1600000000000"/>
+         created_at="1500000000000" updated_at="1600000000000"/>
 
   <rules id="11" name="Slow" plugin_rule_key="S002"
          plugin_config_key="S2" plugin_name="xoo"
          priority="3" status="BETA"
          is_template="[true]" template_id="[null]"
          tags="[null]" system_tags="[null]"
-         created_at="2014-05-10" updated_at="2014-05-11"
-         created_at_ms="2000000000000" updated_at_ms="2100000000000"/>
+         created_at="2000000000000" updated_at="2100000000000"/>
 
   <rules_profiles id="1" name="Parent" kee="parent" language="xoo" parent_kee="[null]" is_default="[false]"/>
 
   <rules_profiles id="2" name="Child" kee="child" language="xoo" parent_kee="parent" is_default="[false]"/>
 
   <active_rules id="1" profile_id="2" rule_id="10" failure_level="4" inheritance="INHERITED"
-                created_at_ms="1500000000000" updated_at_ms="1600000000000"/>
+                created_at="1500000000000" updated_at="1600000000000"/>
 
   <!-- Parent of Active rule 1 -->
   <active_rules id="2" profile_id="1" rule_id="10" failure_level="0" inheritance="[null]"
-                created_at_ms="1700000000000" updated_at_ms="1800000000000"/>
+                created_at="1700000000000" updated_at="1800000000000"/>
 
   <rules_profiles id="3" name="Sonar Way" kee="sonar-way" language="xoo" parent_kee="[null]" is_default="[false]"/>
 
   <active_rules id="3" profile_id="3" rule_id="11" failure_level="3" inheritance="[null]"
-                created_at_ms="2000000000000" updated_at_ms="2100000000000"/>
+                created_at="2000000000000" updated_at="2100000000000"/>
 
 </dataset>
index b3e777b77357349940e0d22bd4b098e55dd3b3be..58647440cac3eeec57eb0a1d5963fefde45cd128 100644 (file)
@@ -6,8 +6,7 @@
          priority="4" status="READY"
          is_template="[false]" template_id="[null]"
          tags="bug,performance" system_tags="cwe"
-         created_at="2014-05-10" updated_at="2014-05-11"
-         created_at_ms="1500000000000" updated_at_ms="1600000000000"
+         created_at="1500000000000" updated_at="1600000000000"
   />
 
 </dataset>
index 3ab588b95e2f7746ddb1e951a1286673f5de9424..aea85a6b647a2cb3affd3a27852200804c834ba3 100644 (file)
@@ -6,8 +6,7 @@
          priority="4" status="REMOVED"
          is_template="[false]" template_id="[null]"
          tags="bug,performance" system_tags="cwe"
-         created_at="2014-05-10" updated_at="2014-05-11"
-         created_at_ms="1500000000000" updated_at_ms="1600000000000"
+         created_at="1500000000000" updated_at="1600000000000"
   />
 
 </dataset>
index 13f34bcd263236ae51ae5033619bdd5cfd110541..dfe3352fd3fe067dfd58e7af2a3cdb12347bba55 100644 (file)
@@ -7,8 +7,7 @@
          priority="4" status="READY"
          is_template="[true]" template_id="[null]"
          tags="bug,performance" system_tags="cwe"
-         created_at="2014-05-10" updated_at="2014-05-11"
-         created_at_ms="1500000000000" updated_at_ms="1600000000000"
+         created_at="1500000000000" updated_at="1600000000000"
   />
 
   <!-- Custom rule -->
@@ -18,8 +17,7 @@
          priority="3" status="BETA"
          is_template="[false]" template_id="1"
          tags="[null]" system_tags="[null]"
-         created_at="2014-05-10" updated_at="2014-05-11"
-         created_at_ms="2000000000000" updated_at_ms="2100000000000"
+         created_at="2000000000000" updated_at="2100000000000"
   />
 
 </dataset>
index b3e777b77357349940e0d22bd4b098e55dd3b3be..58647440cac3eeec57eb0a1d5963fefde45cd128 100644 (file)
@@ -6,8 +6,7 @@
          priority="4" status="READY"
          is_template="[false]" template_id="[null]"
          tags="bug,performance" system_tags="cwe"
-         created_at="2014-05-10" updated_at="2014-05-11"
-         created_at_ms="1500000000000" updated_at_ms="1600000000000"
+         created_at="1500000000000" updated_at="1600000000000"
   />
 
 </dataset>
index 3ab588b95e2f7746ddb1e951a1286673f5de9424..aea85a6b647a2cb3affd3a27852200804c834ba3 100644 (file)
@@ -6,8 +6,7 @@
          priority="4" status="REMOVED"
          is_template="[false]" template_id="[null]"
          tags="bug,performance" system_tags="cwe"
-         created_at="2014-05-10" updated_at="2014-05-11"
-         created_at_ms="1500000000000" updated_at_ms="1600000000000"
+         created_at="1500000000000" updated_at="1600000000000"
   />
 
 </dataset>
index 65e7c7a086651720e8c4948437f83f00c15d6ff6..71b57fca0608247a275ee5e8c7edd8754945b84e 100644 (file)
@@ -6,8 +6,7 @@
          priority="4" status="READY"
          is_template="[false]" template_id="[null]"
          tags="bug,performance" system_tags="cwe"
-         created_at="2014-05-10" updated_at="2014-05-11"
-         created_at_ms="1500000000000" updated_at_ms="1600000000000"
+         created_at="1500000000000" updated_at="1600000000000"
   />
 
   <rules id="2" name="Slow" plugin_rule_key="S002"
@@ -16,7 +15,6 @@
          priority="3" status="BETA"
          is_template="[true]" template_id="[null]"
          tags="[null]" system_tags="[null]"
-         created_at="2014-05-10" updated_at="2014-05-11"
-         created_at_ms="2000000000000" updated_at_ms="2100000000000"
+         created_at="2000000000000" updated_at="2100000000000"
   />
 </dataset>
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1108_drop_rules_date_columns.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1108_drop_rules_date_columns.rb
new file mode 100644 (file)
index 0000000..066ad47
--- /dev/null
@@ -0,0 +1,30 @@
+#
+# SonarQube, open source software quality management tool.
+# Copyright (C) 2008-2014 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.
+#
+
+#
+# SonarQube 5.5
+# SONAR-7330
+#
+class DropRulesDateColumns < ActiveRecord::Migration
+
+  def self.up
+    execute_java_migration('org.sonar.db.version.v55.DropRulesDateColumns')
+  end
+end
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1109_rename_rules_long_dates.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1109_rename_rules_long_dates.rb
new file mode 100644 (file)
index 0000000..e5abf30
--- /dev/null
@@ -0,0 +1,33 @@
+#
+# SonarQube, open source software quality management tool.
+# Copyright (C) 2008-2014 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.
+#
+
+#
+# SonarQube 5.5
+# SONAR-7330
+#
+class RenameRulesLongDates < ActiveRecord::Migration
+
+  def self.up
+    rename_column 'rules', 'created_at_ms', 'created_at'
+    rename_column 'rules', 'updated_at_ms', 'updated_at'
+  end
+
+end
+
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1110_drop_active_rules_date_columns.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1110_drop_active_rules_date_columns.rb
new file mode 100644 (file)
index 0000000..dfd018d
--- /dev/null
@@ -0,0 +1,30 @@
+#
+# SonarQube, open source software quality management tool.
+# Copyright (C) 2008-2014 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.
+#
+
+#
+# SonarQube 5.5
+# SONAR-7330
+#
+class DropActiveRulesDateColumns < ActiveRecord::Migration
+
+  def self.up
+    execute_java_migration('org.sonar.db.version.v55.DropActiveRulesDateColumns')
+  end
+end
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1111_rename_active_rules_long_dates.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1111_rename_active_rules_long_dates.rb
new file mode 100644 (file)
index 0000000..284d8c8
--- /dev/null
@@ -0,0 +1,33 @@
+#
+# SonarQube, open source software quality management tool.
+# Copyright (C) 2008-2014 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.
+#
+
+#
+# SonarQube 5.5
+# SONAR-7330
+#
+class RenameActiveRulesLongDates < ActiveRecord::Migration
+
+  def self.up
+    rename_column 'active_rules', 'created_at_ms', 'created_at'
+    rename_column 'active_rules', 'updated_at_ms', 'updated_at'
+  end
+
+end
+
index 0112420c6c799b0453965c75e832574da4f33b83..2b4613889bba61d9a0578fe0710d9580a7c3ec5a 100644 (file)
@@ -41,8 +41,8 @@ public class ActiveRuleDto {
   private Integer severity;
   private String inheritance;
 
-  private long createdAtInMs;
-  private long updatedAtInMs;
+  private long createdAt;
+  private long updatedAt;
 
   // These fields do not exists in db, it's only retrieve by joins
   private Integer parentId;
@@ -139,21 +139,21 @@ public class ActiveRuleDto {
     return StringUtils.equals(OVERRIDES, inheritance);
   }
 
-  public long getUpdatedAtInMs() {
-    return updatedAtInMs;
+  public long getUpdatedAt() {
+    return updatedAt;
   }
 
-  public ActiveRuleDto setUpdatedAtInMs(long updatedAtInMs) {
-    this.updatedAtInMs = updatedAtInMs;
+  public ActiveRuleDto setUpdatedAt(long updatedAt) {
+    this.updatedAt = updatedAt;
     return this;
   }
 
-  public long getCreatedAtInMs() {
-    return createdAtInMs;
+  public long getCreatedAt() {
+    return createdAt;
   }
 
-  public ActiveRuleDto setCreatedAtInMs(long createdAtInMs) {
-    this.createdAtInMs = createdAtInMs;
+  public ActiveRuleDto setCreatedAt(long createdAt) {
+    this.createdAt = createdAt;
     return this;
   }
 
index 3bf350b777c93c8cd069ffae277ac8f4e9c93b6d..22ed140485f8258d7ff5cdd0828638168934cc69 100644 (file)
@@ -74,8 +74,8 @@ public class RuleDto {
 
   private RuleKey key;
 
-  private long createdAtInMs;
-  private long updatedAtInMs;
+  private long createdAt;
+  private long updatedAt;
 
   public RuleKey getKey() {
     if (key == null) {
@@ -378,21 +378,21 @@ public class RuleDto {
     return this;
   }
 
-  public long getCreatedAtInMs() {
-    return createdAtInMs;
+  public long getCreatedAt() {
+    return createdAt;
   }
 
-  public RuleDto setCreatedAtInMs(long createdAt) {
-    this.createdAtInMs = createdAt;
+  public RuleDto setCreatedAt(long createdAt) {
+    this.createdAt = createdAt;
     return this;
   }
 
-  public long getUpdatedAtInMs() {
-    return updatedAtInMs;
+  public long getUpdatedAt() {
+    return updatedAt;
   }
 
-  public RuleDto setUpdatedAtInMs(long updatedAt) {
-    this.updatedAtInMs = updatedAt;
+  public RuleDto setUpdatedAt(long updatedAt) {
+    this.updatedAt = updatedAt;
     return this;
   }
 
index 744620671a65cf31915e6ffe0789de11ae8e0372..67e20f40c64493e386478cb580962187c64ef792 100644 (file)
@@ -29,7 +29,7 @@ import org.sonar.db.MyBatis;
 
 public class DatabaseVersion {
 
-  public static final int LAST_VERSION = 1107;
+  public static final int LAST_VERSION = 1111;
 
   /**
    * The minimum supported version which can be upgraded. Lower
index b4d9ac00205bf89bb3cf310796754ae10a030f17..6859cac4175e8df2aa8d7500f410aac7072b491f 100644 (file)
@@ -72,8 +72,10 @@ import org.sonar.db.version.v54.RemovePreviewPermission;
 import org.sonar.db.version.v55.AddActiveRulesLongDateColumns;
 import org.sonar.db.version.v55.AddIssuesType;
 import org.sonar.db.version.v55.AddRulesLongDateColumns;
-import org.sonar.db.version.v55.FeedActiveRulesLongDateColumns;
 import org.sonar.db.version.v55.DeleteMeasuresWithCharacteristicId;
+import org.sonar.db.version.v55.DropActiveRulesDateColumns;
+import org.sonar.db.version.v55.DropRulesDateColumns;
+import org.sonar.db.version.v55.FeedActiveRulesLongDateColumns;
 import org.sonar.db.version.v55.FeedIssueTypes;
 import org.sonar.db.version.v55.FeedRulesLongDateColumns;
 
@@ -148,9 +150,10 @@ public class MigrationStepModule extends Module {
       DeleteMeasuresWithCharacteristicId.class,
       AddActiveRulesLongDateColumns.class,
       FeedActiveRulesLongDateColumns.class,
-      DeleteMeasuresWithCharacteristicId.class,
       AddIssuesType.class,
-      FeedIssueTypes.class
+      FeedIssueTypes.class,
+      DropRulesDateColumns.class,
+      DropActiveRulesDateColumns.class
       );
   }
 }
diff --git a/sonar-db/src/main/java/org/sonar/db/version/v55/DropActiveRulesDateColumns.java b/sonar-db/src/main/java/org/sonar/db/version/v55/DropActiveRulesDateColumns.java
new file mode 100644 (file)
index 0000000..73d4805
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact 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.db.version.v55;
+
+import com.google.common.annotations.VisibleForTesting;
+import java.sql.SQLException;
+import org.sonar.db.Database;
+import org.sonar.db.version.DdlChange;
+import org.sonar.db.version.DropColumnsBuilder;
+
+/**
+ * Drop the following columns from the active_rules table :
+ * - created_at
+ * - updated_at
+ */
+public class DropActiveRulesDateColumns extends DdlChange {
+
+  private final Database db;
+
+  public DropActiveRulesDateColumns(Database db) {
+    super(db);
+    this.db = db;
+  }
+
+  @Override
+  public void execute(Context context) throws SQLException {
+    context.execute(generateSql());
+  }
+
+  @VisibleForTesting
+  String generateSql() {
+    return new DropColumnsBuilder(db.getDialect(), "active_rules",
+      "created_at", "updated_at")
+      .build();
+  }
+
+}
diff --git a/sonar-db/src/main/java/org/sonar/db/version/v55/DropRulesDateColumns.java b/sonar-db/src/main/java/org/sonar/db/version/v55/DropRulesDateColumns.java
new file mode 100644 (file)
index 0000000..38f440c
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact 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.db.version.v55;
+
+import com.google.common.annotations.VisibleForTesting;
+import java.sql.SQLException;
+import org.sonar.db.Database;
+import org.sonar.db.version.DdlChange;
+import org.sonar.db.version.DropColumnsBuilder;
+
+/**
+ * Drop the following columns from the rules table :
+ * - created_at
+ * - updated_at
+ */
+public class DropRulesDateColumns extends DdlChange {
+
+  private final Database db;
+
+  public DropRulesDateColumns(Database db) {
+    super(db);
+    this.db = db;
+  }
+
+  @Override
+  public void execute(Context context) throws SQLException {
+    context.execute(generateSql());
+  }
+
+  @VisibleForTesting
+  String generateSql() {
+    return new DropColumnsBuilder(db.getDialect(), "rules",
+      "created_at", "updated_at")
+      .build();
+  }
+
+}
index a79f5e4103e1bac9b985ef5fb63019ecaa720681..17e6aa4a274213008835b2383d4ec6f98cf601aa 100644 (file)
@@ -12,8 +12,8 @@
     r.plugin_rule_key as "rulefield",
     r.plugin_name as "repository",
     qp.kee as "profileKey",
-    a.created_at_ms as "createdAtInMs",
-    a.updated_at_ms as "updatedAtInMs"
+    a.created_at as "createdAt",
+    a.updated_at as "updatedAt"
   </sql>
 
   <sql id="activeRuleKeyJoin">
@@ -29,8 +29,8 @@
     a.failure_level as severity,
     a.inheritance as inheritance,
     active_rule_parent.id as parentId,
-    a.created_at_ms as "createdAtInMs",
-    a.updated_at_ms as "updatedAtInMs"
+    a.created_at as "createdAt",
+    a.updated_at as "updatedAt"
   </sql>
 
   <!-- Should be removed when ActiveRuleDao v2 will be removed -->
@@ -54,8 +54,8 @@
   </select>
 
   <insert id="insert" parameterType="ActiveRule" keyColumn="id" useGeneratedKeys="true" keyProperty="id">
-    INSERT INTO active_rules (profile_id, rule_id, failure_level, inheritance, created_at_ms, updated_at_ms)
-    VALUES (#{profileId}, #{ruleId}, #{severity}, #{inheritance}, #{createdAtInMs}, #{updatedAtInMs})
+    INSERT INTO active_rules (profile_id, rule_id, failure_level, inheritance, created_at, updated_at)
+    VALUES (#{profileId}, #{ruleId}, #{severity}, #{inheritance}, #{createdAt}, #{updatedAt})
   </insert>
 
   <update id="update" parameterType="ActiveRule">
@@ -64,7 +64,7 @@
     rule_id=#{ruleId},
     failure_level=#{severity},
     inheritance=#{inheritance},
-    updated_at_ms=#{updatedAtInMs}
+    updated_at=#{updatedAt}
     WHERE id=#{id}
   </update>
 
index 4d98081a923d333c2c49c1cf8b27aef283cdd218..3492b3e79ffc3279dd87f87fe90c8366ccb30ee8 100644 (file)
@@ -31,8 +31,8 @@
     r.effort_to_fix_description as "effortToFixDescription",
     r.tags as "tagsField",
     r.system_tags as "systemTagsField",
-    r.created_at_ms as "createdAtInMs",
-    r.updated_at_ms as "updatedAtInMs"
+    r.created_at as "createdAt",
+    r.updated_at as "updatedAt"
   </sql>
 
   <select id="selectAll" resultType="Rule">
         AND r.plugin_config_key = #{query.configKey}
       </if>
     </where>
-    ORDER BY r.updated_at_ms DESC
+    ORDER BY r.updated_at DESC
   </select>
 
   <update id="update" parameterType="Rule">
     effort_to_fix_description=#{effortToFixDescription},
     tags=#{tagsField},
     system_tags=#{systemTagsField},
-    updated_at_ms=#{updatedAtInMs}
+    updated_at=#{updatedAt}
     WHERE id=#{id}
   </update>
 
     characteristic_id, default_characteristic_id, remediation_function, default_remediation_function,
     remediation_coeff, default_remediation_coeff, remediation_offset, default_remediation_offset,
     effort_to_fix_description, tags, system_tags, note_data, note_user_login, note_created_at, note_updated_at,
-    created_at_ms, updated_at_ms)
+    created_at, updated_at)
   </sql>
 
   <insert id="insert" parameterType="Rule" keyColumn="id" useGeneratedKeys="true" keyProperty="id">
     #{subCharacteristicId}, #{defaultSubCharacteristicId}, #{remediationFunction}, #{defaultRemediationFunction},
     #{remediationCoefficient}, #{defaultRemediationCoefficient}, #{remediationOffset}, #{defaultRemediationOffset},
     #{effortToFixDescription}, #{tagsField}, #{systemTagsField}, #{noteData}, #{noteUserLogin}, #{noteCreatedAt},
-    #{noteUpdatedAt}, #{createdAtInMs}, #{updatedAtInMs})
+    #{noteUpdatedAt}, #{createdAt}, #{updatedAt})
   </insert>
 
   <insert id="batchInsert" parameterType="Rule" useGeneratedKeys="false">
     #{remediationOffset,jdbcType=VARCHAR}, #{defaultRemediationOffset,jdbcType=VARCHAR},
     #{effortToFixDescription}, #{tagsField}, #{systemTagsField}, #{noteData}, #{noteUserLogin}, #{noteCreatedAt},
     #{noteUpdatedAt,jdbcType=TIMESTAMP},
-    #{createdAtInMs,jdbcType=BIGINT}, #{updatedAtInMs,jdbcType=BIGINT}
+    #{createdAt,jdbcType=BIGINT}, #{updatedAt,jdbcType=BIGINT}
     )
   </insert>
 
index 4ecc1757f515ef5c6e6bcd9dec251aab8dae9ae8..d8da5b65e7fc0ca823dec420b1165aa7f1d87fe2 100644 (file)
@@ -383,7 +383,12 @@ INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1102');
 INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1103');
 INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1104');
 INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1105');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1106');
 INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1107');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1108');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1109');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1110');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1111');
 
 INSERT INTO USERS(ID, LOGIN, NAME, EMAIL, EXTERNAL_IDENTITY, EXTERNAL_IDENTITY_PROVIDER, CRYPTED_PASSWORD, SALT, CREATED_AT, UPDATED_AT, REMEMBER_TOKEN, REMEMBER_TOKEN_EXPIRES_AT) VALUES (1, 'admin', 'Administrator', '', 'admin', 'sonarqube', 'a373a0e667abb2604c1fd571eb4ad47fe8cc0878', '48bc4b0d93179b5103fd3885ea9119498e9d161b', '1418215735482', '1418215735482', null, null);
 ALTER TABLE USERS ALTER COLUMN ID RESTART WITH 2;
index bedb09a40c6b92ca92234224b36755b00e6bec48..93c5661b02a715e6d723911389a95afcadbe09c5 100644 (file)
@@ -124,10 +124,8 @@ CREATE TABLE "RULES" (
   "EFFORT_TO_FIX_DESCRIPTION" VARCHAR(4000),
   "TAGS" VARCHAR(4000),
   "SYSTEM_TAGS" VARCHAR(4000),
-  "CREATED_AT" TIMESTAMP,
-  "UPDATED_AT" TIMESTAMP,
-  "CREATED_AT_MS" BIGINT,
-  "UPDATED_AT_MS" BIGINT
+  "CREATED_AT" BIGINT,
+  "UPDATED_AT" BIGINT
 );
 
 
@@ -262,10 +260,8 @@ CREATE TABLE "ACTIVE_RULES" (
   "RULE_ID" INTEGER NOT NULL,
   "FAILURE_LEVEL" INTEGER NOT NULL,
   "INHERITANCE" VARCHAR(10),
-  "CREATED_AT" TIMESTAMP,
-  "UPDATED_AT" TIMESTAMP,
-  "CREATED_AT_MS" BIGINT,
-  "UPDATED_AT_MS" BIGINT
+  "CREATED_AT" BIGINT,
+  "UPDATED_AT" BIGINT
 );
 
 CREATE TABLE "NOTIFICATIONS" (
index 28208807e43c81e71d641b80eaa6353b6f50bdd8..8da2677ea43c3840214406b369f2efda6740e670 100644 (file)
@@ -223,8 +223,8 @@ public class RuleDaoTest {
       .setRemediationOffset("5min")
       .setDefaultRemediationOffset("10h")
       .setEffortToFixDescription("squid.S115.effortToFix")
-      .setCreatedAtInMs(1500000000000L)
-      .setUpdatedAtInMs(2000000000000L);
+      .setCreatedAt(1500000000000L)
+      .setUpdatedAt(2000000000000L);
     underTest.insert(dbTester.getSession(), newRule);
     dbTester.getSession().commit();
 
@@ -252,8 +252,8 @@ public class RuleDaoTest {
     assertThat(ruleDto.getRemediationOffset()).isEqualTo("5min");
     assertThat(ruleDto.getDefaultRemediationOffset()).isEqualTo("10h");
     assertThat(ruleDto.getEffortToFixDescription()).isEqualTo("squid.S115.effortToFix");
-    assertThat(ruleDto.getCreatedAtInMs()).isEqualTo(1500000000000L);
-    assertThat(ruleDto.getUpdatedAtInMs()).isEqualTo(2000000000000L);
+    assertThat(ruleDto.getCreatedAt()).isEqualTo(1500000000000L);
+    assertThat(ruleDto.getUpdatedAt()).isEqualTo(2000000000000L);
   }
 
   @Test
@@ -284,7 +284,7 @@ public class RuleDaoTest {
       .setRemediationOffset("5min")
       .setDefaultRemediationOffset("10h")
       .setEffortToFixDescription("squid.S115.effortToFix")
-      .setUpdatedAtInMs(2000000000000L);
+      .setUpdatedAt(2000000000000L);
 
     underTest.update(dbTester.getSession(), ruleToUpdate);
     dbTester.getSession().commit();
@@ -312,8 +312,8 @@ public class RuleDaoTest {
     assertThat(ruleDto.getRemediationOffset()).isEqualTo("5min");
     assertThat(ruleDto.getDefaultRemediationOffset()).isEqualTo("10h");
     assertThat(ruleDto.getEffortToFixDescription()).isEqualTo("squid.S115.effortToFix");
-    assertThat(ruleDto.getCreatedAtInMs()).isEqualTo(1500000000000L);
-    assertThat(ruleDto.getUpdatedAtInMs()).isEqualTo(2000000000000L);
+    assertThat(ruleDto.getCreatedAt()).isEqualTo(1500000000000L);
+    assertThat(ruleDto.getUpdatedAt()).isEqualTo(2000000000000L);
   }
 
   @Test
index e81f60853626832ae5297cc075e4378d9d4fab61..8de7b00ca97e583cdd08d9605bb3157e965cdadf 100644 (file)
@@ -29,6 +29,6 @@ public class MigrationStepModuleTest {
   public void verify_count_of_added_MigrationStep_types() {
     ComponentContainer container = new ComponentContainer();
     new MigrationStepModule().configure(container);
-    assertThat(container.size()).isEqualTo(56);
+    assertThat(container.size()).isEqualTo(60);
   }
 }
diff --git a/sonar-db/src/test/java/org/sonar/db/version/v55/DropActiveRulesDateColumnsTest.java b/sonar-db/src/test/java/org/sonar/db/version/v55/DropActiveRulesDateColumnsTest.java
new file mode 100644 (file)
index 0000000..29b2bf5
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact 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.db.version.v55;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.sonar.db.Database;
+import org.sonar.db.dialect.PostgreSql;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+public class DropActiveRulesDateColumnsTest {
+
+  DropActiveRulesDateColumns migration;
+
+  Database database;
+
+  @Before
+  public void setUp() {
+    database = mock(Database.class);
+    migration = new DropActiveRulesDateColumns(database);
+  }
+
+  @Test
+  public void generate_sql_on_postgresql() {
+    when(database.getDialect()).thenReturn(new PostgreSql());
+    assertThat(migration.generateSql()).isEqualTo(
+      "ALTER TABLE active_rules DROP COLUMN created_at, DROP COLUMN updated_at"
+      );
+  }
+
+}
diff --git a/sonar-db/src/test/java/org/sonar/db/version/v55/DropRulesDateColumnsTest.java b/sonar-db/src/test/java/org/sonar/db/version/v55/DropRulesDateColumnsTest.java
new file mode 100644 (file)
index 0000000..f05eda3
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact 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.db.version.v55;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.sonar.db.Database;
+import org.sonar.db.dialect.PostgreSql;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+public class DropRulesDateColumnsTest {
+
+  DropRulesDateColumns migration;
+
+  Database database;
+
+  @Before
+  public void setUp() {
+    database = mock(Database.class);
+    migration = new DropRulesDateColumns(database);
+  }
+
+  @Test
+  public void generate_sql_on_postgresql() {
+    when(database.getDialect()).thenReturn(new PostgreSql());
+    assertThat(migration.generateSql()).isEqualTo(
+      "ALTER TABLE rules DROP COLUMN created_at, DROP COLUMN updated_at"
+      );
+  }
+
+}
index 423fc21f0c09cb6bbf4de327193e295eaecbafeb..497ceafcf7fead629d3eb7d7f06f5d54fdd9f2e6 100644 (file)
@@ -1,13 +1,13 @@
 <dataset>
     <rules tags="[null]" system_tags="[null]" id="1" plugin_rule_key="NewRuleKey" plugin_name="plugin" name="new name" description="new description" status="DEPRECATED"
-           plugin_config_key="NewConfigKey" priority="0" is_template="[true]" language="dart" created_at="2013-12-16" updated_at="2013-12-17" template_id="3"
+           plugin_config_key="NewConfigKey" priority="0" is_template="[true]" language="dart" template_id="3"
            note_data="[null]" note_user_login="[null]" note_created_at="[null]" note_updated_at="[null]"
            characteristic_id="100" default_characteristic_id="101"
            remediation_function="linear" default_remediation_function="linear_offset"
            remediation_coeff="1h" default_remediation_coeff="5d"
            remediation_offset="5min" default_remediation_offset="10h"
            effort_to_fix_description="squid.S115.effortToFix"
-           created_at_ms="[null]" updated_at_ms="[null]"
+           created_at="[null]" updated_at="[null]"
             />
   <rules_parameters id="1" rule_id="1" name="max" param_type="INTEGER" default_value="30" description="My Parameter"/>
 </dataset>
index de4e4e969ca5fb50fa2e1293752592f85f1e7e9e..75036a0b3165d80df64652b513f23d8cb7553171 100644 (file)
@@ -1,12 +1,12 @@
 <dataset>
     <rules tags="[null]" system_tags="[null]" id="1" plugin_rule_key="NewRuleKey" plugin_name="plugin" name="new name" description="new description" status="DEPRECATED"
-           plugin_config_key="NewConfigKey" priority="0" is_template="[true]" language="dart" created_at="2013-12-16" updated_at="2013-12-17" template_id="3"
+           plugin_config_key="NewConfigKey" priority="0" is_template="[true]" language="dart" template_id="3"
            note_data="[null]" note_user_login="[null]" note_created_at="[null]" note_updated_at="[null]"
            characteristic_id="100" default_characteristic_id="101"
            remediation_function="linear" default_remediation_function="linear_offset"
            remediation_coeff="1h" default_remediation_coeff="5d"
            remediation_offset="5min" default_remediation_offset="10h"
            effort_to_fix_description="squid.S115.effortToFix"
-           created_at_ms="[null]" updated_at_ms="[null]"
+           created_at="[null]" updated_at="[null]"
             />
 </dataset>
index 59a8dae0f4f1e832ac345b9f5d5c606672ed2dc4..1ae601a67abeffff22b88629e16757b03c0975e8 100644 (file)
@@ -7,8 +7,7 @@
          remediation_coeff="1h" default_remediation_coeff="5d"
          remediation_offset="5min" default_remediation_offset="10h"
          effort_to_fix_description="squid.S115.effortToFix"
-         created_at="2014-05-10" updated_at="2014-05-11"
-         created_at_ms="1500000000000" updated_at_ms="1600000000000"
+         created_at="1500000000000" updated_at="1600000000000"
   />
 
   <rules tags="[null]" system_tags="[null]" id="2" plugin_rule_key="AvoidNull" plugin_name="squid" name="Avoid Null" description="Should avoid NULL" status="REMOVED"
@@ -18,8 +17,7 @@
          remediation_coeff="[null]" default_remediation_coeff="[null]"
          remediation_offset="[null]" default_remediation_offset="[null]"
          effort_to_fix_description="[null]"
-         created_at="2014-05-10" updated_at="2014-05-11"
-         created_at_ms="1500000000000" updated_at_ms="1600000000000"
+         created_at="1500000000000" updated_at="1600000000000"
   />
 
   <rules tags="[null]" system_tags="[null]" id="3" plugin_rule_key="AvoidNull" plugin_name="manual" name="Manual Rule" description="Should not appear" status="READY"
@@ -29,8 +27,7 @@
          remediation_coeff="[null]" default_remediation_coeff="[null]"
          remediation_offset="[null]" default_remediation_offset="[null]"
          effort_to_fix_description="[null]"
-         created_at="2014-05-10" updated_at="2014-05-11"
-         created_at_ms="1500000000000" updated_at_ms="1600000000000"
+         created_at="1500000000000" updated_at="1600000000000"
   />
 
 </dataset>
index f76ce5c6545c0913a09af51875b2c971aab6e502..f4c6a9bc32f0d384c9a72b904cbf7a11615076ae 100644 (file)
@@ -2,9 +2,9 @@
 
   <rules tags="[null]" system_tags="[null]" id="1" plugin_rule_key="AvoidNull" plugin_name="checkstyle"
          name="Avoid Null" description="Should avoid NULL" status="READY" description_format="HTML"
-         created_at_ms="1500000000000" updated_at_ms="1600000000000"/>
+         created_at="1500000000000" updated_at="1600000000000"/>
   <rules tags="[null]" system_tags="[null]" id="2" plugin_rule_key="AvoidNull" plugin_name="manual" name="Manual Rule"
          description="Should not appear" status="READY" description_format="HTML"
-         created_at_ms="1500000000000" updated_at_ms="1600000000000"/>
+         created_at="1500000000000" updated_at="1600000000000"/>
 
 </dataset>
index 079e238d48ceb394158621bc96c5c72cf9b6b775..65d9b4e5a45c17e239f9cc576611d75bbf2d4c40 100644 (file)
@@ -2,13 +2,13 @@
 
   <rules tags="[null]" system_tags="[null]" id="1" plugin_rule_key="AvoidNull" plugin_name="checkstyle"
          name="Avoid Null" description="Should avoid NULL" status="READY"
-         created_at_ms="1500000000000" updated_at_ms="1600000000000"/>
+         created_at="1500000000000" updated_at="1600000000000"/>
   <rules_parameters id="1" rule_id="1" name="myParameter" param_type="plop" default_value="plouf"
                     description="My Parameter"/>
 
   <rules tags="[null]" system_tags="[null]" id="2" plugin_rule_key="Unused" plugin_name="unused" name="Unused Rule"
          description="Not used" status="REMOVED"
-         created_at_ms="1500000000000" updated_at_ms="1600000000000"/>
+         created_at="1500000000000" updated_at="1600000000000"/>
   <rules_parameters id="2" rule_id="2" name="otherParam" param_type="plop" default_value="plouf"
                     description="Other Parameter"/>
 
index 94c54d474374f8024fed37af99c1b067e9790785..c4d8d267be2b8de73cb00231fbdf0d55c9094839 100644 (file)
@@ -4,24 +4,21 @@
          plugin_config_key="S1" plugin_name="java" description="[null]" priority="4" status="READY"
          is_template="[false]" template_id="[null]"
          tags="bug,performance" system_tags="cwe"
-         created_at="2014-05-10" updated_at="2014-05-11"
-         created_at_ms="1500000000000" updated_at_ms="1600000000000"
+         created_at="1500000000000" updated_at="1600000000000"
   />
 
   <rules id="2" name="Slow" plugin_rule_key="S002"
          plugin_config_key="S2" plugin_name="java" description="[null]" priority="4" status="BETA"
          is_template="[false]" template_id="[null]"
          tags="[null]" system_tags="[null]"
-         created_at="2014-05-10" updated_at="2014-05-11"
-         created_at_ms="1500000000000" updated_at_ms="1600000000000"
+         created_at="1500000000000" updated_at="1600000000000"
   />
 
   <rules id="10" name="Removed" plugin_rule_key="S003"
          plugin_config_key="S3" plugin_name="java" description="[null]" priority="4" status="REMOVED"
          is_template="[false]" template_id="[null]"
          tags="[null]" system_tags="[null]"
-         created_at="2014-05-10" updated_at="2014-05-11"
-         created_at_ms="1500000000000" updated_at_ms="1600000000000"
+         created_at="1500000000000" updated_at="1600000000000"
   />
 
 </dataset>
index b80cd56461f1526c71764169fa254d36532efb29..c75cc533f1114c10397f94c0f23cad43d8f51026 100644 (file)
@@ -3,7 +3,6 @@
   <rules tags="[null]" system_tags="[null]" id="1" plugin_rule_key="AvoidNull" plugin_name="checkstyle"
          name="Avoid Null" description="Should avoid NULL" status="READY"
          plugin_config_key="AvoidNull" priority="2" is_template="[false]" language="golo"
-         created_at="2011-04-25 01:05:00" template_id="2" description_format="HTML"
-         created_at_ms="1500000000000" updated_at_ms="1600000000000"/>
+         created_at="1500000000000" updated_at="1600000000000"/>
 
 </dataset>
index e60f87e31b3fd2d9b65006be3ff2b2abe08db8b2..3907b7d23c6d7185890a8db450b40bb4fbf17bf0 100644 (file)
@@ -1,7 +1,7 @@
 <dataset>
   <rules tags="[null]" system_tags="[null]" id="1" plugin_rule_key="AvoidNull" plugin_name="checkstyle"
          name="Avoid Null" description="Should avoid NULL" status="READY"
-         created_at_ms="1500000000000" updated_at_ms="1600000000000"/>
+         created_at="1500000000000" updated_at="1600000000000"/>
 
   <rules_parameters id="1" rule_id="1" name="max" param_type="STRING" default_value="^[a-z]+(\.[a-z][a-z0-9]*)*$"
                     description="Regular expression used to check the package names against."/>
index 8ac19218587685a345142afa556e8c233431608f..2eb61cc702971ce922727f32d6da675cbdeb9e14 100644 (file)
@@ -1,7 +1,7 @@
 <dataset>
   <rules tags="[null]" system_tags="[null]" id="1" plugin_rule_key="AvoidNull" plugin_name="checkstyle"
          name="Avoid Null" description="Should avoid NULL" status="READY"
-         created_at_ms="1500000000000" updated_at_ms="1600000000000"/>
+         created_at="1500000000000" updated_at="1600000000000"/>
 
   <rules_parameters id="1" rule_id="1" name="max" param_type="INTEGER" default_value="30" description="My Parameter"/>
 </dataset>