]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-3248 purge REVIEW_COMMENTS and ACTION_PLANS
authorsimonbrandhof <simon.brandhof@gmail.com>
Mon, 13 Feb 2012 15:04:24 +0000 (16:04 +0100)
committersimonbrandhof <simon.brandhof@gmail.com>
Mon, 13 Feb 2012 15:04:24 +0000 (16:04 +0100)
This commit includes the new index on REVIEWS.RESOURCE_ID and the renaming of ACTION_PLANS.DEAD_LINE to DEADLINE

sonar-core/src/main/java/org/sonar/core/purge/PurgeDao.java
sonar-core/src/main/java/org/sonar/core/purge/PurgeMapper.java
sonar-core/src/main/java/org/sonar/jpa/entity/SchemaMigration.java
sonar-core/src/main/resources/org/sonar/core/persistence/rows-derby.sql
sonar-core/src/main/resources/org/sonar/core/persistence/schema-derby.ddl
sonar-core/src/main/resources/org/sonar/core/purge/PurgeMapper.xml
sonar-core/src/test/java/org/sonar/core/purge/PurgeDaoTest.java
sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/shouldDeleteProject.xml
sonar-server/src/main/webapp/WEB-INF/db/migrate/191_create_review.rb
sonar-server/src/main/webapp/WEB-INF/db/migrate/258_add_index_on_review_resource_id.rb [new file with mode: 0644]
sonar-server/src/main/webapp/WEB-INF/db/migrate/259_rename_action_plans_columns.rb [new file with mode: 0644]

index fbf5f663e7900852801ddeb554d2b9f3ac05c856..8a7bbf5f9a554b29121758a5453caba0bae43a35 100644 (file)
@@ -140,6 +140,9 @@ public class PurgeDao {
     mapper.deleteResourceUserRoles(resourceId);
     mapper.deleteResourceManualMeasures(resourceId);
     mapper.deleteResourceReviews(resourceId);
+    mapper.deleteResourceReviewComments(resourceId);
+    mapper.deleteResourceActionPlansReviews(resourceId);
+    mapper.deleteResourceActionPlans(resourceId);
     mapper.deleteResourceEvents(resourceId);
     mapper.deleteResource(resourceId);
   }
index 3eb54da5b9b9184b80d58f803ec94627ec6b7986..964b734aac6c1640c83c75966ce6bcc0215a511e 100644 (file)
@@ -71,8 +71,14 @@ public interface PurgeMapper {
 
   void deleteResourceReviews(long resourceId);
 
+  void deleteResourceReviewComments(long resourceId);
+
   void deleteResourceEvents(long resourceId);
 
+  void deleteResourceActionPlans(long resourceId);
+
+  void deleteResourceActionPlansReviews(long resourceId);
+
   void closeResourceReviews(long resourceId);
 
   List<PurgeableSnapshotDto> selectPurgeableSnapshotsWithEvents(long resourceId);
index 5b77f98c42337b2fe264e61db3ac176be6b62e3a..58325dfd4bcbcecf0111d1f5aa421e1fa18ba270 100644 (file)
@@ -34,7 +34,7 @@ public class SchemaMigration {
 
   public final static int VERSION_UNKNOWN = -1;
 
-  public static final int LAST_VERSION = 257;
+  public static final int LAST_VERSION = 259;
   public static final int VERSION_2_13 = 241;
 
   public final static String TABLE_NAME = "schema_migrations";
index 26a063c5a2e171b6658f03d102d4aa9ae0d66a0e..59c4d9f02cd818c1e8ed8ba2d93e29a407a04149 100644 (file)
@@ -175,6 +175,8 @@ INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('254');
 INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('255');
 INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('256');
 INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('257');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('258');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('259');
 
 INSERT INTO USERS(ID, LOGIN, NAME, EMAIL, CRYPTED_PASSWORD, SALT, CREATED_AT, UPDATED_AT, REMEMBER_TOKEN, REMEMBER_TOKEN_EXPIRES_AT) VALUES (1, 'admin', 'Administrator', '', 'a373a0e667abb2604c1fd571eb4ad47fe8cc0878', '48bc4b0d93179b5103fd3885ea9119498e9d161b', '2011-09-26 22:27:48.0', '2011-09-26 22:27:48.0', null, null);
 ALTER TABLE USERS ALTER COLUMN ID RESTART WITH 2;
index 327f48e4e7cf9991cdcbad2bd922bbdbe3129ceb..2de07173e61cade3135afbf0d20eb56a58503dce 100644 (file)
@@ -476,7 +476,7 @@ CREATE TABLE "ACTION_PLANS" (
   "USER_ID" INTEGER,
   "NAME" VARCHAR(200),
   "DESCRIPTION" VARCHAR(1000),
-  "DEAD_LINE" TIMESTAMP,
+  "DEADLINE" TIMESTAMP,
   "USER_LOGIN" VARCHAR(40),
   "PROJECT_ID" INTEGER,
   "STATUS" VARCHAR(10),
@@ -604,6 +604,8 @@ CREATE INDEX "INDEX_ACTIVE_RULE_NOTES_ON_ACTIVE_RULE_ID" ON "ACTIVE_RULE_NOTES"
 
 CREATE INDEX "INDEX_RULE_NOTES_ON_ACTIVE_RULE_ID" ON "RULE_NOTES" ("RULE_ID");
 
+CREATE INDEX "REVIEWS_RID" ON "REVIEWS" ("RESOURCE_ID");
+
 
 -- ----------------------------------------------
 -- DDL Statements for keys
index 815a1920462880d8033584498ca40b195c89e855..e62a75ad90b23952dfcbc959158edc7d8f91bc51 100644 (file)
     delete from reviews where resource_id=#{id}
   </delete>
 
+  <delete id="deleteResourceReviewComments" parameterType="long">
+    delete from review_comments rc where exists (select * from reviews r where rc.review_id=r.id and r.resource_id=#{id})
+  </delete>
+
   <delete id="deleteResourceEvents" parameterType="long">
     delete from events where resource_id=#{id}
   </delete>
 
+  <delete id="deleteResourceActionPlans" parameterType="long">
+    delete from action_plans where project_id=#{id}
+  </delete>
+
+  <delete id="deleteResourceActionPlansReviews" parameterType="long">
+    delete from action_plans_reviews apr where exists (select * from action_plans ap where ap.id=apr.action_plan_id and ap.project_id=#{id})
+  </delete>
+
   <update id="setSnapshotIsLastToFalse" parameterType="long">
     update snapshots set islast=${_false} where project_id=#{id}
   </update>
index 5d4e07a847afb44dfbe77693e354ce463b46e180..df17a128b8f92fb23732fa8cdbd062216825b1bd 100644 (file)
@@ -174,7 +174,7 @@ public class PurgeDaoTest extends DaoTestCase {
   public void shouldDeleteProject() {
     setupData("shouldDeleteProject");
     dao.deleteProject(1L);
-    assertEmptyTables("projects", "snapshots");
+    assertEmptyTables("projects", "snapshots", "action_plans", "action_plans_reviews", "reviews", "review_comments");
   }
 
   static final class SnapshotMatcher extends BaseMatcher<PurgeableSnapshotDto> {
index 88e87f2583bff5151aad30c65ecda9f5f22b72f5..472874f6deeb9ddf5f60baa33dfc81c6547cc673 100644 (file)
              build_date="2008-12-02 13:58:00.00"
              version="[null]" path="[null]"/>
 
+  <action_plans id="1" project_id="1" user_id="100" name="SHORT_TERM" description="[null]" deadline="[null]"
+                user_login="igor" status="[null]" created_at="[null]" updated_at="[null]" />
+
+  <action_plans_reviews action_plan_id="1" review_id="250" />
+
+  <reviews id="1" project_id="1" resource_id="1" status="CLOSED"
+        rule_failure_permanent_id="1" resolution="[null]" created_at="[null]" resource_line="200" severity="BLOCKER"
+        user_id="300" assignee_id="300" rule_id="500" manual_violation="[true]" manual_severity="[false]" title="[null]"/>
+
+  <reviews id="2" project_id="1" resource_id="1" status="CLOSED"
+          rule_failure_permanent_id="2" resolution="[null]" created_at="[null]" resource_line="200" severity="BLOCKER"
+          user_id="300" assignee_id="300" rule_id="500" manual_violation="[true]" manual_severity="[false]" title="[null]"/>
+
 
   <!-- modules -->
   <projects id="2" enabled="[true]" root_id="1"
index 5e28dc013ce64c1dd170cd4ed00dc6410fbc9086..c9178bc50268046a685a504b72fcf38cba008bfe 100644 (file)
@@ -34,7 +34,7 @@ class CreateReview < ActiveRecord::Migration
       t.column 'status',                                               :string,        :null => true,  :limit => 10
       t.column 'severity',                                             :string,        :null => true,  :limit => 10
       t.column 'rule_failure_permanent_id',    :integer,       :null => true   
-         t.column 'project_id',                                        :integer,       :null => true
+           t.column 'project_id',                                      :integer,       :null => true
       t.column 'resource_id',                                  :integer,       :null => true   
       t.column 'resource_line',                                :integer,       :null => true      
     end
diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/258_add_index_on_review_resource_id.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/258_add_index_on_review_resource_id.rb
new file mode 100644 (file)
index 0000000..40810ba
--- /dev/null
@@ -0,0 +1,34 @@
+#
+# Sonar, entreprise quality control tool.
+# Copyright (C) 2008-2012 SonarSource
+# mailto:contact AT sonarsource DOT com
+#
+# Sonar 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.
+#
+# Sonar 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 Sonar; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02
+#
+
+#
+# Sonar 2.14
+#
+class AddIndexOnReviewResourceId < ActiveRecord::Migration
+
+  def self.up
+    begin
+      add_index('reviews', 'resource_id', :name => 'reviews_rid')
+    rescue
+      # already exists
+    end
+  end
+
+end
diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/259_rename_action_plans_columns.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/259_rename_action_plans_columns.rb
new file mode 100644 (file)
index 0000000..9ea0116
--- /dev/null
@@ -0,0 +1,30 @@
+#
+# Sonar, entreprise quality control tool.
+# Copyright (C) 2008-2012 SonarSource
+# mailto:contact AT sonarsource DOT com
+#
+# Sonar 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.
+#
+# Sonar 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 Sonar; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02
+#
+
+#
+# Sonar 2.14
+#
+class RenameActionPlansColumns < ActiveRecord::Migration
+
+  def self.up
+    rename_column(:action_plans, :dead_line, :deadline)
+  end
+
+end