]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-7330 Add rules long date columns
authorJulien Lancelot <julien.lancelot@sonarsource.com>
Tue, 16 Feb 2016 17:55:30 +0000 (18:55 +0100)
committerJulien Lancelot <julien.lancelot@sonarsource.com>
Wed, 17 Feb 2016 10:53:29 +0000 (11:53 +0100)
35 files changed:
server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/insert-result.xml
server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/insert_all-result.xml
server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/insert_parameter-result.xml
server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/insert_parameter.xml
server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/selectAll.xml
server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/selectById.xml
server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/selectNonManual.xml
server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/selectParameters.xml
server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/select_by_name.xml
server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/select_by_rule_key.xml
server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/select_by_sub_characteristic_id.xml
server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/select_parameters_by_language.xml
server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/select_parameters_by_rule_id.xml
server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/select_parameters_by_rule_ids.xml
server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/update-result.xml
server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/update.xml
server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/update_parameter-result.xml
server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/update_parameter.xml
server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1100_add_rules_long_date_columns.rb [new file with mode: 0644]
server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1101_feed_rules_long_date_columns.rb [new file with mode: 0644]
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/AddRulesLongDateColumns.java [new file with mode: 0644]
sonar-db/src/main/java/org/sonar/db/version/v55/FeedRulesLongDateColumns.java [new file with mode: 0644]
sonar-db/src/main/java/org/sonar/db/version/v55/package-info.java [new file with mode: 0644]
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/version/MigrationStepModuleTest.java
sonar-db/src/test/java/org/sonar/db/version/v55/AddRulesLongDateColumnsTest.java [new file with mode: 0644]
sonar-db/src/test/java/org/sonar/db/version/v55/FeedRulesLongDateColumnsTest.java [new file with mode: 0644]
sonar-db/src/test/resources/org/sonar/db/rule/RuleDaoTest/selectEnabledAndNonManual.xml
sonar-db/src/test/resources/org/sonar/db/rule/RuleDaoTest/shared.xml
sonar-db/src/test/resources/org/sonar/db/version/v55/AddRulesLongDateColumnsTest/schema.sql [new file with mode: 0644]
sonar-db/src/test/resources/org/sonar/db/version/v55/FeedRulesLongDateColumnsTest/execute.xml [new file with mode: 0644]
sonar-db/src/test/resources/org/sonar/db/version/v55/FeedRulesLongDateColumnsTest/schema.sql [new file with mode: 0644]

index 144ea0906f9323628e6eff67462a1ee6314e034e..77e5d99adb8789b9ab6fcd67083fbdf4b9b4b22b 100644 (file)
@@ -1,33 +1,15 @@
-<!--
-  ~ 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.
-  -->
-
 <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-16" 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" description_format="MARKDOWN"
-      />
+         created_at="2013-12-16" updated_at="2013-12-16"
+         created_at_ms="[null]" updated_at_ms="[null]"
+  />
 
 </dataset>
index 1aa7b053d0d7174ad7f9f84f7c796f21df5712d4..f063e486961593f209f68ad14a615286404e92b0 100644 (file)
@@ -1,23 +1,3 @@
-<!--
-  ~ 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.
-  -->
-
 <dataset>
 
   <rules tags="[null]" system_tags="[null]" id="1" plugin_rule_key="NewRuleKey" plugin_name="plugin" name="new name" description="new description" status="DEPRECATED"
@@ -28,6 +8,7 @@
          remediation_coeff="1h" default_remediation_coeff="5d"
          remediation_offset="5min" default_remediation_offset="10h"
          effort_to_fix_description="squid.S115.effortToFix" description_format="HTML"
+         created_at_ms="[null]" updated_at_ms="[null]"
       />
 
   <rules tags="[null]" system_tags="[null]" id="2" plugin_rule_key="NewRuleKey2" plugin_name="plugin2" name="new name2" description="new description2" status="BETA"
@@ -38,6 +19,7 @@
          remediation_coeff="5d" default_remediation_coeff="1h"
          remediation_offset="10h" default_remediation_offset="5min"
          effort_to_fix_description="squid.S115.effortToFix2" description_format="MARKDOWN"
+         created_at_ms="[null]" updated_at_ms="[null]"
       />
 
 </dataset>
index 52d587b2b0f73935720c4424e228ff95eef7d94d..423fc21f0c09cb6bbf4de327193e295eaecbafeb 100644 (file)
@@ -7,6 +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_ms="[null]" updated_at_ms="[null]"
             />
   <rules_parameters id="1" rule_id="1" name="max" param_type="INTEGER" default_value="30" description="My Parameter"/>
 </dataset>
index 149ebb938ae49db5e8b538c6f6f985ee5cd3f3a4..de4e4e969ca5fb50fa2e1293752592f85f1e7e9e 100644 (file)
@@ -7,5 +7,6 @@
            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]"
             />
 </dataset>
index 57fc4fecb51bc07c1c2de86d08f49d282d71cfd1..7d870c0d234edf0e69327dafc691472136243c27 100644 (file)
@@ -8,6 +8,7 @@
     remediation_coeff="1h" default_remediation_coeff="5d"
     remediation_offset="5min" default_remediation_offset="10h"
     effort_to_fix_description="squid.S115.effortToFix"
+         created_at_ms="1500000000000" updated_at_ms="1600000000000"
   />
 
 </dataset>
index 0f2d818a01dce52c5a7346f70b76f0d6aea355a3..90c57a60a714da801a06524a188643f80188c105 100644 (file)
@@ -1,6 +1,10 @@
 <dataset>
 
-  <rules tags="[null]" system_tags="[null]" id="1" plugin_rule_key="AvoidComparison" plugin_name="checkstyle" name="Avoid Comparison" description="Should avoid ==" status="READY" description_format="HTML"/>
-  <rules tags="[null]" system_tags="[null]" id="2" plugin_rule_key="AvoidNull" plugin_name="checkstyle" name="Avoid Null" description="Should avoid NULL" status="READY" description_format="HTML"/>
+  <rules tags="[null]" system_tags="[null]" id="1" plugin_rule_key="AvoidComparison" plugin_name="checkstyle"
+         name="Avoid Comparison" description="Should avoid ==" status="READY" description_format="HTML"
+         created_at_ms="1500000000000" updated_at_ms="1600000000000"/>
+  <rules tags="[null]" system_tags="[null]" id="2" 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"/>
 
 </dataset>
index c69e0d858642d3ba0e75742269af429bfe8bbb8d..f76ce5c6545c0913a09af51875b2c971aab6e502 100644 (file)
@@ -1,6 +1,10 @@
 <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" description_format="HTML"/>
-  <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"/>
+  <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"/>
+  <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"/>
 
 </dataset>
index 9d9c8de23436300a619e78dab29a25dba1c020c2..6e32ecd70208ac12e3aeeca3086da88f30cd4dcf 100644 (file)
@@ -1,6 +1,9 @@
 <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"/>
-  <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="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"/>
+  <rules_parameters id="1" rule_id="1" name="myParameter" param_type="plop" default_value="plouf"
+                    description="My Parameter"/>
 
 </dataset>
index 0f2d818a01dce52c5a7346f70b76f0d6aea355a3..90c57a60a714da801a06524a188643f80188c105 100644 (file)
@@ -1,6 +1,10 @@
 <dataset>
 
-  <rules tags="[null]" system_tags="[null]" id="1" plugin_rule_key="AvoidComparison" plugin_name="checkstyle" name="Avoid Comparison" description="Should avoid ==" status="READY" description_format="HTML"/>
-  <rules tags="[null]" system_tags="[null]" id="2" plugin_rule_key="AvoidNull" plugin_name="checkstyle" name="Avoid Null" description="Should avoid NULL" status="READY" description_format="HTML"/>
+  <rules tags="[null]" system_tags="[null]" id="1" plugin_rule_key="AvoidComparison" plugin_name="checkstyle"
+         name="Avoid Comparison" description="Should avoid ==" status="READY" description_format="HTML"
+         created_at_ms="1500000000000" updated_at_ms="1600000000000"/>
+  <rules tags="[null]" system_tags="[null]" id="2" 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"/>
 
 </dataset>
index 0f2d818a01dce52c5a7346f70b76f0d6aea355a3..90c57a60a714da801a06524a188643f80188c105 100644 (file)
@@ -1,6 +1,10 @@
 <dataset>
 
-  <rules tags="[null]" system_tags="[null]" id="1" plugin_rule_key="AvoidComparison" plugin_name="checkstyle" name="Avoid Comparison" description="Should avoid ==" status="READY" description_format="HTML"/>
-  <rules tags="[null]" system_tags="[null]" id="2" plugin_rule_key="AvoidNull" plugin_name="checkstyle" name="Avoid Null" description="Should avoid NULL" status="READY" description_format="HTML"/>
+  <rules tags="[null]" system_tags="[null]" id="1" plugin_rule_key="AvoidComparison" plugin_name="checkstyle"
+         name="Avoid Comparison" description="Should avoid ==" status="READY" description_format="HTML"
+         created_at_ms="1500000000000" updated_at_ms="1600000000000"/>
+  <rules tags="[null]" system_tags="[null]" id="2" 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"/>
 
 </dataset>
index 55795399ec292ca77a16064a48ee1d479fa4910d..6c058a33fe9a3eaffd35d005cccb85c6f59baaf6 100644 (file)
@@ -3,59 +3,69 @@
   <!-- Root characteristic -->
   <characteristics id="1" kee="PORTABILITY" name="Portability" parent_id="[null]" characteristic_order="1"
                    enabled="[true]"
-                   created_at="2013-11-20" updated_at="2013-11-22"/>
+                   created_at="2013-11-20" updated_at="2013-11-22"
+                   created_at_ms="1500000000000" updated_at_ms="1600000000000"/>
 
   <!-- Sub characteristics of root characteristic -->
   <characteristics id="2" kee="COMPILER_RELATED_PORTABILITY" name="Compiler related portability" parent_id="1" characteristic_order="[null]"
                    enabled="[true]"
-                   created_at="2013-11-20" updated_at="2013-11-22"/>
+                   created_at="2013-11-20" updated_at="2013-11-22"
+                   created_at_ms="1500000000000" updated_at_ms="1600000000000"/>
   <characteristics id="3" kee="HARDWARE_RELATED_PORTABILITY" name="Hardware related portability " parent_id="1" characteristic_order="[null]"
                    enabled="[true]"
-                   created_at="2013-11-20" updated_at="2013-11-22"/>
+                   created_at="2013-11-20" updated_at="2013-11-22"
+                   created_at_ms="1500000000000" updated_at_ms="1600000000000"/>
 
   <!-- Disabled root characteristic -->
   <characteristics id="10" kee="DISABLED_ROOT_CHARACTERISTIC" name="Disabled root characteristic" parent_id="[null]" characteristic_order="2"
                    enabled="[false]"
-                   created_at="2013-11-20" updated_at="2013-11-22"/>
+                   created_at="2013-11-20" updated_at="2013-11-22"
+                   created_at_ms="1500000000000" updated_at_ms="1600000000000"/>
 
   <!-- Disabled characteristic -->
   <characteristics id="11" kee="DISABLED_CHARACTERISTIC" name="Disabled characteristic" parent_id="10" characteristic_order="[null]"
                    enabled="[false]"
-                   created_at="2013-11-20" updated_at="2013-11-22"/>
+                   created_at="2013-11-20" updated_at="2013-11-22"
+                   created_at_ms="1500000000000" updated_at_ms="1600000000000"/>
 
   <!-- Rule linked to a sub characteristic -->
   <rules tags="[null]" system_tags="[null]" id="1" plugin_rule_key="UselessImportCheck" plugin_name="squid" name="UselessImportCheck" description="Useless imports should be removed" status="READY"
          characteristic_id="2" default_characteristic_id="50"
          remediation_function="LINEAR_OFFSET" default_remediation_function="LINEAR_OFFSET"
          remediation_coeff="5d" default_remediation_coeff="5d"
-         remediation_offset="10h" default_remediation_offset="10h" updated_at="2014-02-19"/>
+         remediation_offset="10h" default_remediation_offset="10h" updated_at="2014-02-19"
+         created_at_ms="1500000000000" updated_at_ms="1600000000000"/>
 
   <!-- Rule linked to a sub characteristic -->
   <rules tags="[null]" system_tags="[null]" id="2" plugin_rule_key="LeftCurlyBraceStartLineCheck" plugin_name="squid" name="LeftCurlyBraceStartLineCheck" description="Left curly braces should be located at the beginning of lines of code" status="READY"
          characteristic_id="3" default_characteristic_id="50"
          remediation_function="LINEAR_OFFSET" default_remediation_function="LINEAR_OFFSET"
          remediation_coeff="5d" default_remediation_coeff="5d"
-         remediation_offset="10h" default_remediation_offset="10h" updated_at="2014-02-19"/>
+         remediation_offset="10h" default_remediation_offset="10h" updated_at="2014-02-19"
+         created_at_ms="1500000000000" updated_at_ms="1600000000000"/>
 
   <!-- Rule linked to a disabled sub characteristic -> should never be returned -->
   <rules tags="[null]" system_tags="[null]" id="3" plugin_rule_key="CallToFileDeleteOnExitMethod" plugin_name="squid" name="CallToFileDeleteOnExitMethod" description="CallToFileDeleteOnExitMethod" status="READY"
          characteristic_id="11" default_characteristic_id="50"
          remediation_function="LINEAR" default_remediation_function="LINEAR_OFFSET"
          remediation_coeff="5d" default_remediation_coeff="5d"
-         remediation_offset="[null]" default_remediation_offset="10h" updated_at="2014-02-19"/>
+         remediation_offset="[null]" default_remediation_offset="10h" updated_at="2014-02-19"
+         created_at_ms="1500000000000" updated_at_ms="1600000000000"/>
 
   <!-- Removed rule linked to one enable sub characteristic -->
   <rules tags="[null]" system_tags="[null]" id="4" plugin_rule_key="ObjectFinalizeOverridenCallsSuperFinalizeCheck" plugin_name="squid" name="ObjectFinalizeOverridenCallsSuperFinalizeCheck" description="super.finalize() should be called at the end of Object.finalize() implementations" status="REMOVED"
          characteristic_id="3" default_characteristic_id="50"
          remediation_function="LINEAR" default_remediation_function="LINEAR_OFFSET"
          remediation_coeff="5d" default_remediation_coeff="5min"
-         remediation_offset="[null]" default_remediation_offset="10h" updated_at="2014-02-19"/>
+         remediation_offset="[null]" default_remediation_offset="10h" updated_at="2014-02-19"
+         created_at_ms="1500000000000" updated_at_ms="1600000000000"/>
 
   <!-- Rule linked to a sub characteristic, but only default characteristic is linked  -->
   <rules tags="[null]" system_tags="[null]" id="5" plugin_rule_key="RightCurlyBraceStartLineCheck" plugin_name="squid" name="RightCurlyBraceStartLineCheck" description="Right curly braces should be located at the beginning of lines of code" status="READY"
          characteristic_id="[null]" default_characteristic_id="3"
          remediation_function="[null]" default_remediation_function="LINEAR"
          remediation_coeff="[null]" default_remediation_coeff="5d"
-         remediation_offset="[null]" default_remediation_offset="[null]" updated_at="2014-02-19"/>
+         remediation_offset="[null]" default_remediation_offset="[null]" updated_at="2014-02-19"
+         created_at_ms="1500000000000" updated_at_ms="1600000000000"/>
 
 </dataset>
index 7115bda1a0efe1099672a953924d44f136781f63..1514ed39a9e6648bcf931034fba6866fcc72e371 100644 (file)
@@ -1,9 +1,18 @@
 <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"
-         language="xoo"/>
-  <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="READY" language="java"/>
-  <rules_parameters id="2" rule_id="2" name="otherParam" param_type="plop" default_value="plouf" description="Other Parameter"/>
+  <rules tags="[null]" system_tags="[null]" id="1" plugin_rule_key="AvoidNull" plugin_name="checkstyle"
+         name="Avoid Null" description="Should avoid NULL" status="READY"
+         language="xoo"
+         created_at_ms="1500000000000" updated_at_ms="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="READY" language="java"
+         created_at_ms="1500000000000" updated_at_ms="1600000000000"
+  />
+  <rules_parameters id="2" rule_id="2" name="otherParam" param_type="plop" default_value="plouf"
+                    description="Other Parameter"/>
 
 </dataset>
index 887fbbcf91078450589458c797fcc41085a4c67e..079e238d48ceb394158621bc96c5c72cf9b6b775 100644 (file)
@@ -1,8 +1,15 @@
 <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"/>
-  <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"/>
-  <rules_parameters id="2" rule_id="2" name="otherParam" param_type="plop" default_value="plouf" description="Other Parameter"/>
+  <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"/>
+  <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"/>
+  <rules_parameters id="2" rule_id="2" name="otherParam" param_type="plop" default_value="plouf"
+                    description="Other Parameter"/>
 
 </dataset>
index 810129bd7a80629361afe1b3a03edb9f9a68f258..daa28d75172c4c7e4b677a0f08d91bcd6fdbaa96 100644 (file)
@@ -1,10 +1,16 @@
 <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"/>
-    <rules tags="[null]" system_tags="[null]" id="2" plugin_rule_key="Unused" plugin_name="unused" name="Unused Rule" description="Not used" status="REMOVED"/>
+  <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"/>
+  <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"/>
 
-    <rules_parameters id="1" rule_id="1" name="myParameter" param_type="plop" default_value="plouf" description="My Parameter"/>
+  <rules_parameters id="1" rule_id="1" name="myParameter" param_type="plop" default_value="plouf"
+                    description="My Parameter"/>
 
-  <rules_parameters id="2" rule_id="2" name="otherParam" param_type="plop" default_value="plouf" description="Other Parameter"/>
+  <rules_parameters id="2" rule_id="2" name="otherParam" param_type="plop" default_value="plouf"
+                    description="Other Parameter"/>
 
 </dataset>
index ef6433e56f0d5e8068d01740832c67e552769065..dec9f35bb1d3a1444fdcbe9b90b5cadcd4618698 100644 (file)
@@ -1,21 +1,32 @@
 <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="2011-04-25 01:05:00" updated_at="2014-01-01" template_id="3"
-    note_data="My note" note_user_login="admin" note_created_at="2013-12-19" note_updated_at="2013-12-20"
-    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" description_format="MARKDOWN"
+  <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="2011-04-25 01:05:00" updated_at="2014-01-01" template_id="3"
+         note_data="My note" note_user_login="admin" note_created_at="2013-12-19" note_updated_at="2013-12-20"
+         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" description_format="MARKDOWN"
+         created_at_ms="1500000000000" updated_at_ms="1600000000000"
   />
 
-  <rules tags="[null]" system_tags="[null]" id="2" plugin_rule_key="Parent1" plugin_name="checkstyle" name="Parent Rule 1" description="Parent Rule 1" status="READY"
-    plugin_config_key="Parent1" priority="2" is_template="[false]" language="golo" created_at="1981-10-24 15:20:00" updated_at="[null]" template_id="[null]"
-    note_created_at="[null]" note_data="[null]" note_updated_at="[null]" note_user_login="[null]" description_format="HTML"/>
+  <rules tags="[null]" system_tags="[null]" id="2" plugin_rule_key="Parent1" plugin_name="checkstyle"
+         name="Parent Rule 1" description="Parent Rule 1" status="READY"
+         plugin_config_key="Parent1" priority="2" is_template="[false]" language="golo" created_at="1981-10-24 15:20:00"
+         updated_at="[null]" template_id="[null]"
+         note_created_at="[null]" note_data="[null]" note_updated_at="[null]" note_user_login="[null]"
+         description_format="HTML"
+         created_at_ms="1500000000000" updated_at_ms="1600000000000"/>
 
-  <rules tags="[null]" system_tags="[null]" id="3" plugin_rule_key="Parent2" plugin_name="checkstyle" name="Parent Rule 2" description="Parent Rule 2" status="READY"
-    plugin_config_key="Parent2" priority="2" is_template="[false]" language="dart" created_at="1982-12-14 03:15:00" updated_at="[null]" template_id="[null]"
-    note_created_at="[null]" note_data="[null]" note_updated_at="[null]" note_user_login="[null]" description_format="HTML"/>
+  <rules tags="[null]" system_tags="[null]" id="3" plugin_rule_key="Parent2" plugin_name="checkstyle"
+         name="Parent Rule 2" description="Parent Rule 2" status="READY"
+         plugin_config_key="Parent2" priority="2" is_template="[false]" language="dart" created_at="1982-12-14 03:15:00"
+         updated_at="[null]" template_id="[null]"
+         note_created_at="[null]" note_data="[null]" note_updated_at="[null]" note_user_login="[null]"
+         description_format="HTML"
+         created_at_ms="1500000000000" updated_at_ms="1600000000000"/>
 
 </dataset>
index e0e99d245495fd63410b7c0f69a16e4046f58853..95e5f4c23ff456f9c160e285ebffa72929124537 100644 (file)
@@ -1,12 +1,21 @@
 <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"
-    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"/>
+  <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"/>
 
-  <rules tags="[null]" system_tags="[null]" id="2" plugin_rule_key="Parent1" plugin_name="checkstyle" name="Parent Rule 1" description="Parent Rule 1" status="READY"
-    plugin_config_key="Parent1" priority="2" is_template="[false]" language="golo" created_at="1981-10-24 15:20:00" description_format="HTML"/>
+  <rules tags="[null]" system_tags="[null]" id="2" plugin_rule_key="Parent1" plugin_name="checkstyle"
+         name="Parent Rule 1" description="Parent Rule 1" status="READY"
+         plugin_config_key="Parent1" priority="2" is_template="[false]" language="golo" created_at="1981-10-24 15:20:00"
+         description_format="HTML"
+         created_at_ms="1500000000000" updated_at_ms="1600000000000"/>
 
-  <rules tags="[null]" system_tags="[null]" id="3" plugin_rule_key="Parent2" plugin_name="checkstyle" name="Parent Rule 2" description="Parent Rule 2" status="READY"
-    plugin_config_key="Parent2" priority="2" is_template="[false]" language="dart" created_at="1982-12-14 03:15:00" description_format="HTML"/>
+  <rules tags="[null]" system_tags="[null]" id="3" plugin_rule_key="Parent2" plugin_name="checkstyle"
+         name="Parent Rule 2" description="Parent Rule 2" status="READY"
+         plugin_config_key="Parent2" priority="2" is_template="[false]" language="dart" created_at="1982-12-14 03:15:00"
+         description_format="HTML"
+         created_at_ms="1500000000000" updated_at_ms="1600000000000"/>
 
 </dataset>
index e18ca3e4c481e5bc9f3f5a5a78cdf97e2a8b7d1e..e60f87e31b3fd2d9b65006be3ff2b2abe08db8b2 100644 (file)
@@ -1,5 +1,8 @@
 <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"/>
+  <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"/>
 
-    <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."/>
+  <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."/>
 </dataset>
index 20c201d738d412f3bda4c1b61869d69b8aada6e7..8ac19218587685a345142afa556e8c233431608f 100644 (file)
@@ -1,5 +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"/>
+  <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"/>
 
-    <rules_parameters id="1" rule_id="1" name="max" param_type="INTEGER" default_value="30" description="My Parameter"/>
+  <rules_parameters id="1" rule_id="1" name="max" param_type="INTEGER" default_value="30" description="My Parameter"/>
 </dataset>
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1100_add_rules_long_date_columns.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1100_add_rules_long_date_columns.rb
new file mode 100644 (file)
index 0000000..54db7d7
--- /dev/null
@@ -0,0 +1,31 @@
+#
+# 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 AddRulesLongDateColumns < ActiveRecord::Migration
+
+  def self.up
+    execute_java_migration('org.sonar.db.version.v55.AddRulesLongDateColumns')
+  end
+
+end
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1101_feed_rules_long_date_columns.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1101_feed_rules_long_date_columns.rb
new file mode 100644 (file)
index 0000000..57cf3aa
--- /dev/null
@@ -0,0 +1,31 @@
+#
+# 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 FeedRulesLongDateColumns < ActiveRecord::Migration
+
+  def self.up
+    execute_java_migration('org.sonar.db.version.v55.FeedRulesLongDateColumns')
+  end
+
+end
index 2f78c4142354097d6dd48506b3377f1c719d5dbb..ec8ebbc2ba8540dfb144ccb980ed633a62e428d4 100644 (file)
@@ -29,7 +29,7 @@ import org.sonar.db.MyBatis;
 
 public class DatabaseVersion {
 
-  public static final int LAST_VERSION = 1017;
+  public static final int LAST_VERSION = 1101;
 
   /**
    * The minimum supported version which can be upgraded. Lower
index 96e0865367ada5d0b72e30af744366172c51b3c5..1c472d444fbf363ac55251842f498ad35b29207a 100644 (file)
@@ -69,6 +69,8 @@ import org.sonar.db.version.v54.MigrateQualityGatesConditions;
 import org.sonar.db.version.v54.MigrateUsersIdentity;
 import org.sonar.db.version.v54.RemoveComponentPageProperties;
 import org.sonar.db.version.v54.RemovePreviewPermission;
+import org.sonar.db.version.v55.AddRulesLongDateColumns;
+import org.sonar.db.version.v55.FeedRulesLongDateColumns;
 
 public class MigrationStepModule extends Module {
   @Override
@@ -133,7 +135,11 @@ public class MigrationStepModule extends Module {
       MigrateQualityGatesConditions.class,
       MigrateDisabledUsersToOnlyKeepLoginAndName.class,
       RemovePreviewPermission.class,
-      IncreaseProjectsNameColumnsSize.class
+      IncreaseProjectsNameColumnsSize.class,
+
+      // 5.5
+      AddRulesLongDateColumns.class,
+      FeedRulesLongDateColumns.class
     );
   }
 }
diff --git a/sonar-db/src/main/java/org/sonar/db/version/v55/AddRulesLongDateColumns.java b/sonar-db/src/main/java/org/sonar/db/version/v55/AddRulesLongDateColumns.java
new file mode 100644 (file)
index 0000000..727d927
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * 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 java.sql.SQLException;
+import org.sonar.db.Database;
+import org.sonar.db.version.AddColumnsBuilder;
+import org.sonar.db.version.DdlChange;
+
+import static org.sonar.db.version.BigDecimalColumnDef.newBigDecimalColumnDefBuilder;
+
+/**
+ * Add the following columns to the rules table :
+ * - created_at_ms
+ * - updated_at_ms
+ */
+public class AddRulesLongDateColumns extends DdlChange {
+
+  private final Database db;
+
+  public AddRulesLongDateColumns(Database db) {
+    super(db);
+    this.db = db;
+  }
+
+  @Override
+  public void execute(Context context) throws SQLException {
+    context.execute(generateSql());
+  }
+
+  private String generateSql() {
+    return new AddColumnsBuilder(db.getDialect(), "rules")
+      .addColumn(newBigDecimalColumnDefBuilder().setColumnName("created_at_ms").setIsNullable(true).build())
+      .addColumn(newBigDecimalColumnDefBuilder().setColumnName("updated_at_ms").setIsNullable(true).build())
+      .build();
+  }
+
+}
diff --git a/sonar-db/src/main/java/org/sonar/db/version/v55/FeedRulesLongDateColumns.java b/sonar-db/src/main/java/org/sonar/db/version/v55/FeedRulesLongDateColumns.java
new file mode 100644 (file)
index 0000000..7325ff9
--- /dev/null
@@ -0,0 +1,80 @@
+/*
+ * 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 java.sql.SQLException;
+import java.util.Date;
+import org.sonar.api.utils.System2;
+import org.sonar.db.Database;
+import org.sonar.db.version.BaseDataChange;
+import org.sonar.db.version.MassUpdate;
+import org.sonar.db.version.Select;
+import org.sonar.db.version.SqlStatement;
+
+public class FeedRulesLongDateColumns extends BaseDataChange {
+
+  private final System2 system;
+
+  public FeedRulesLongDateColumns(Database db, System2 system) {
+    super(db);
+    this.system = system;
+  }
+
+  @Override
+  public void execute(Context context) throws SQLException {
+    final long now = system.now();
+
+    MassUpdate massUpdate = context.prepareMassUpdate();
+    massUpdate.select("SELECT r.id, r.created_at, r.updated_at FROM rules r WHERE created_at_ms IS NULL OR updated_at_ms IS NULL");
+    massUpdate.update("UPDATE rules SET created_at_ms=?, updated_at_ms=? WHERE id=?");
+    massUpdate.rowPluralName("rules");
+    massUpdate.execute(new MigrationHandler(now));
+  }
+
+  private static class MigrationHandler implements MassUpdate.Handler{
+
+    private final long now;
+
+    public MigrationHandler(long now) {
+      this.now = now;
+    }
+
+    @Override
+    public boolean handle(Select.Row row, SqlStatement update) throws SQLException {
+      Long id = row.getNullableLong(1);
+      Date createdAt = row.getNullableDate(2);
+      Date updatedAt = row.getNullableDate(3);
+
+      if (createdAt == null) {
+        update.setLong(1, now);
+      } else {
+        update.setLong(1, Math.min(now, createdAt.getTime()));
+      }
+      if (updatedAt == null) {
+        update.setLong(2, now);
+      } else {
+        update.setLong(2, Math.min(now, updatedAt.getTime()));
+      }
+      update.setLong(3, id);
+      return true;
+    }
+  }
+
+}
diff --git a/sonar-db/src/main/java/org/sonar/db/version/v55/package-info.java b/sonar-db/src/main/java/org/sonar/db/version/v55/package-info.java
new file mode 100644 (file)
index 0000000..c6e3adb
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * 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.
+ */
+@ParametersAreNonnullByDefault
+package org.sonar.db.version.v55;
+
+import javax.annotation.ParametersAreNonnullByDefault;
+
index 1b93040984ae9fdca0845ed115f2989853340582..0d25eca3ba1c7ed8f7e877f79e78ae9851d00911 100644 (file)
@@ -377,6 +377,8 @@ INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1013');
 INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1014');
 INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1015');
 INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1017');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1100');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1101');
 
 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 d4fb90a114e4f9f458f454ccf98378e61407f30b..37bcdbd716a7179ef5af79400f8729e46a20e776 100644 (file)
@@ -143,7 +143,9 @@ CREATE TABLE "RULES" (
   "TAGS" VARCHAR(4000),
   "SYSTEM_TAGS" VARCHAR(4000),
   "CREATED_AT" TIMESTAMP,
-  "UPDATED_AT" TIMESTAMP
+  "UPDATED_AT" TIMESTAMP,
+  "CREATED_AT_MS" BIGINT,
+  "UPDATED_AT_MS" BIGINT
 );
 
 
index c766bebda7dc6a409e99abb383857783482f52c6..a3153c66f31e8b09c80349a89ad31319e9b251dc 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(51);
+    assertThat(container.size()).isEqualTo(53);
   }
 }
diff --git a/sonar-db/src/test/java/org/sonar/db/version/v55/AddRulesLongDateColumnsTest.java b/sonar-db/src/test/java/org/sonar/db/version/v55/AddRulesLongDateColumnsTest.java
new file mode 100644 (file)
index 0000000..8e29ecb
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * 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 java.sql.Types;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.sonar.api.utils.System2;
+import org.sonar.db.DbTester;
+import org.sonar.db.version.MigrationStep;
+
+public class AddRulesLongDateColumnsTest {
+
+  @Rule
+  public DbTester db = DbTester.createForSchema(System2.INSTANCE, AddRulesLongDateColumnsTest.class, "schema.sql");
+
+  MigrationStep migration;
+
+  @Before
+  public void setUp() {
+    migration = new AddRulesLongDateColumns(db.database());
+  }
+
+  @Test
+  public void update_columns() throws Exception {
+    migration.execute();
+
+    db.assertColumnDefinition("rules", "created_at_ms", Types.BIGINT, null);
+    db.assertColumnDefinition("rules", "updated_at_ms", Types.BIGINT, null);
+  }
+
+}
diff --git a/sonar-db/src/test/java/org/sonar/db/version/v55/FeedRulesLongDateColumnsTest.java b/sonar-db/src/test/java/org/sonar/db/version/v55/FeedRulesLongDateColumnsTest.java
new file mode 100644 (file)
index 0000000..84da347
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * 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.Rule;
+import org.junit.Test;
+import org.sonar.api.utils.System2;
+import org.sonar.db.DbTester;
+import org.sonar.db.version.MigrationStep;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+public class FeedRulesLongDateColumnsTest {
+
+  @Rule
+  public DbTester db = DbTester.createForSchema(System2.INSTANCE, FeedRulesLongDateColumnsTest.class, "schema.sql");
+
+  static final long NOW = 1500000000000L;
+
+  System2 system = mock(System2.class);
+
+  MigrationStep migration = new FeedRulesLongDateColumns(db.database(), system);
+
+  @Before
+  public void setUp() throws Exception {
+    when(system.now()).thenReturn(NOW);
+  }
+
+  @Test
+  public void execute() throws Exception {
+    db.prepareDbUnit(getClass(), "execute.xml");
+
+    migration.execute();
+
+    assertThat(db.countSql("select count(*) from rules where created_at_ms is not null and updated_at_ms is not null")).isEqualTo(3);
+    // Only 1 rules not updated
+    assertThat(db.countSql("select count(*) from rules where created_at_ms='1000000000000' and updated_at_ms='1000000000000'")).isEqualTo(1);
+  }
+
+}
index fe85e591078a7df48046145358b8f0ed90990752..59a8dae0f4f1e832ac345b9f5d5c606672ed2dc4 100644 (file)
@@ -6,7 +6,10 @@
          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"/>
+         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"
+  />
 
   <rules tags="[null]" system_tags="[null]" id="2" plugin_rule_key="AvoidNull" plugin_name="squid" name="Avoid Null" description="Should avoid NULL" status="REMOVED"
          note_data="[null]" note_user_login="[null]" note_created_at="[null]" description_format="HTML"
          remediation_function="[null]" default_remediation_function="[null]"
          remediation_coeff="[null]" default_remediation_coeff="[null]"
          remediation_offset="[null]" default_remediation_offset="[null]"
-         effort_to_fix_description="[null]"/>
+         effort_to_fix_description="[null]"
+         created_at="2014-05-10" updated_at="2014-05-11"
+         created_at_ms="1500000000000" updated_at_ms="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"
          note_data="[null]" note_user_login="[null]" note_created_at="[null]" description_format="HTML"
@@ -22,6 +28,9 @@
          remediation_function="[null]" default_remediation_function="[null]"
          remediation_coeff="[null]" default_remediation_coeff="[null]"
          remediation_offset="[null]" default_remediation_offset="[null]"
-         effort_to_fix_description="[null]"/>
+         effort_to_fix_description="[null]"
+         created_at="2014-05-10" updated_at="2014-05-11"
+         created_at_ms="1500000000000" updated_at_ms="1600000000000"
+  />
 
 </dataset>
index d7d86c81a35b7f8e95bb96632dd1b9b5ed3252e6..ff4211adfceec5784711321f20d1e48797c6da54 100644 (file)
@@ -3,10 +3,16 @@
   <rules id="1" name="Null Pointer" plugin_rule_key="S001"
          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" />
+         tags="bug,performance" system_tags="cwe"
+         created_at="2014-05-10" updated_at="2014-05-11"
+         created_at_ms="1500000000000" updated_at_ms="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]" />
+         tags="[null]" system_tags="[null]"
+         created_at="2014-05-10" updated_at="2014-05-11"
+         created_at_ms="1500000000000" updated_at_ms="1600000000000"
+  />
 </dataset>
diff --git a/sonar-db/src/test/resources/org/sonar/db/version/v55/AddRulesLongDateColumnsTest/schema.sql b/sonar-db/src/test/resources/org/sonar/db/version/v55/AddRulesLongDateColumnsTest/schema.sql
new file mode 100644 (file)
index 0000000..0c7c17f
--- /dev/null
@@ -0,0 +1,31 @@
+CREATE TABLE "RULES" (
+  "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
+  "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL,
+  "PLUGIN_NAME" VARCHAR(255) NOT NULL,
+  "DESCRIPTION" VARCHAR(16777215),
+  "DESCRIPTION_FORMAT" VARCHAR(20),
+  "PRIORITY" INTEGER,
+  "IS_TEMPLATE" BOOLEAN DEFAULT FALSE,
+  "TEMPLATE_ID" INTEGER,
+  "PLUGIN_CONFIG_KEY" VARCHAR(500),
+  "NAME" VARCHAR(200),
+  "STATUS" VARCHAR(40),
+  "LANGUAGE" VARCHAR(20),
+  "NOTE_DATA" CLOB(2147483647),
+  "NOTE_USER_LOGIN" VARCHAR(255),
+  "NOTE_CREATED_AT" TIMESTAMP,
+  "NOTE_UPDATED_AT" TIMESTAMP,
+  "CHARACTERISTIC_ID" INTEGER,
+  "DEFAULT_CHARACTERISTIC_ID" INTEGER,
+  "REMEDIATION_FUNCTION" VARCHAR(20),
+  "DEFAULT_REMEDIATION_FUNCTION" VARCHAR(20),
+  "REMEDIATION_COEFF" VARCHAR(20),
+  "DEFAULT_REMEDIATION_COEFF" VARCHAR(20),
+  "REMEDIATION_OFFSET" VARCHAR(20),
+  "DEFAULT_REMEDIATION_OFFSET" VARCHAR(20),
+  "EFFORT_TO_FIX_DESCRIPTION" VARCHAR(4000),
+  "TAGS" VARCHAR(4000),
+  "SYSTEM_TAGS" VARCHAR(4000),
+  "CREATED_AT" TIMESTAMP,
+  "UPDATED_AT" TIMESTAMP
+);
diff --git a/sonar-db/src/test/resources/org/sonar/db/version/v55/FeedRulesLongDateColumnsTest/execute.xml b/sonar-db/src/test/resources/org/sonar/db/version/v55/FeedRulesLongDateColumnsTest/execute.xml
new file mode 100644 (file)
index 0000000..e46c1ac
--- /dev/null
@@ -0,0 +1,29 @@
+<dataset>
+
+  <rules id="1" name="Null Pointer" plugin_rule_key="S001"
+         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-12" updated_at="2014-05-13"
+         created_at_ms="[null]" updated_at_ms="[null]"
+  />
+
+  <!-- re-entrant migration - ignore the issues that are already fed with new dates -->
+  <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="1000000000000" updated_at_ms="1000000000000"
+  />
+
+  <!-- NULL dates -->
+  <rules id="3" name="Down" plugin_rule_key="S003"
+         plugin_config_key="S3" plugin_name="java" description="[null]" priority="4" status="BETA"
+         is_template="[false]" template_id="[null]"
+         tags="[null]" system_tags="[null]"
+         created_at="[null]" updated_at="[null]"
+         created_at_ms="[null]" updated_at_ms="[null]"
+  />
+
+</dataset>
diff --git a/sonar-db/src/test/resources/org/sonar/db/version/v55/FeedRulesLongDateColumnsTest/schema.sql b/sonar-db/src/test/resources/org/sonar/db/version/v55/FeedRulesLongDateColumnsTest/schema.sql
new file mode 100644 (file)
index 0000000..39f299d
--- /dev/null
@@ -0,0 +1,33 @@
+CREATE TABLE "RULES" (
+  "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
+  "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL,
+  "PLUGIN_NAME" VARCHAR(255) NOT NULL,
+  "DESCRIPTION" VARCHAR(16777215),
+  "DESCRIPTION_FORMAT" VARCHAR(20),
+  "PRIORITY" INTEGER,
+  "IS_TEMPLATE" BOOLEAN DEFAULT FALSE,
+  "TEMPLATE_ID" INTEGER,
+  "PLUGIN_CONFIG_KEY" VARCHAR(500),
+  "NAME" VARCHAR(200),
+  "STATUS" VARCHAR(40),
+  "LANGUAGE" VARCHAR(20),
+  "NOTE_DATA" CLOB(2147483647),
+  "NOTE_USER_LOGIN" VARCHAR(255),
+  "NOTE_CREATED_AT" TIMESTAMP,
+  "NOTE_UPDATED_AT" TIMESTAMP,
+  "CHARACTERISTIC_ID" INTEGER,
+  "DEFAULT_CHARACTERISTIC_ID" INTEGER,
+  "REMEDIATION_FUNCTION" VARCHAR(20),
+  "DEFAULT_REMEDIATION_FUNCTION" VARCHAR(20),
+  "REMEDIATION_COEFF" VARCHAR(20),
+  "DEFAULT_REMEDIATION_COEFF" VARCHAR(20),
+  "REMEDIATION_OFFSET" VARCHAR(20),
+  "DEFAULT_REMEDIATION_OFFSET" VARCHAR(20),
+  "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
+);