diff options
author | simonbrandhof <simon.brandhof@gmail.com> | 2012-02-13 16:04:24 +0100 |
---|---|---|
committer | simonbrandhof <simon.brandhof@gmail.com> | 2012-02-13 16:04:24 +0100 |
commit | 1b714ecf1d3bb0930b3724d177d3d0de18d0ef3c (patch) | |
tree | de3f265d5724a6d1f017e9f828c26412b43583eb /sonar-core | |
parent | 5020106e7712cb85bad4449186bb842c19733727 (diff) | |
download | sonarqube-1b714ecf1d3bb0930b3724d177d3d0de18d0ef3c.tar.gz sonarqube-1b714ecf1d3bb0930b3724d177d3d0de18d0ef3c.zip |
SONAR-3248 purge REVIEW_COMMENTS and ACTION_PLANS
This commit includes the new index on REVIEWS.RESOURCE_ID and the renaming of ACTION_PLANS.DEAD_LINE to DEADLINE
Diffstat (limited to 'sonar-core')
8 files changed, 41 insertions, 3 deletions
diff --git a/sonar-core/src/main/java/org/sonar/core/purge/PurgeDao.java b/sonar-core/src/main/java/org/sonar/core/purge/PurgeDao.java index fbf5f663e79..8a7bbf5f9a5 100644 --- a/sonar-core/src/main/java/org/sonar/core/purge/PurgeDao.java +++ b/sonar-core/src/main/java/org/sonar/core/purge/PurgeDao.java @@ -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); } diff --git a/sonar-core/src/main/java/org/sonar/core/purge/PurgeMapper.java b/sonar-core/src/main/java/org/sonar/core/purge/PurgeMapper.java index 3eb54da5b9b..964b734aac6 100644 --- a/sonar-core/src/main/java/org/sonar/core/purge/PurgeMapper.java +++ b/sonar-core/src/main/java/org/sonar/core/purge/PurgeMapper.java @@ -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); diff --git a/sonar-core/src/main/java/org/sonar/jpa/entity/SchemaMigration.java b/sonar-core/src/main/java/org/sonar/jpa/entity/SchemaMigration.java index 5b77f98c423..58325dfd4bc 100644 --- a/sonar-core/src/main/java/org/sonar/jpa/entity/SchemaMigration.java +++ b/sonar-core/src/main/java/org/sonar/jpa/entity/SchemaMigration.java @@ -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"; diff --git a/sonar-core/src/main/resources/org/sonar/core/persistence/rows-derby.sql b/sonar-core/src/main/resources/org/sonar/core/persistence/rows-derby.sql index 26a063c5a2e..59c4d9f02cd 100644 --- a/sonar-core/src/main/resources/org/sonar/core/persistence/rows-derby.sql +++ b/sonar-core/src/main/resources/org/sonar/core/persistence/rows-derby.sql @@ -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; diff --git a/sonar-core/src/main/resources/org/sonar/core/persistence/schema-derby.ddl b/sonar-core/src/main/resources/org/sonar/core/persistence/schema-derby.ddl index 327f48e4e7c..2de07173e61 100644 --- a/sonar-core/src/main/resources/org/sonar/core/persistence/schema-derby.ddl +++ b/sonar-core/src/main/resources/org/sonar/core/persistence/schema-derby.ddl @@ -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 diff --git a/sonar-core/src/main/resources/org/sonar/core/purge/PurgeMapper.xml b/sonar-core/src/main/resources/org/sonar/core/purge/PurgeMapper.xml index 815a1920462..e62a75ad90b 100644 --- a/sonar-core/src/main/resources/org/sonar/core/purge/PurgeMapper.xml +++ b/sonar-core/src/main/resources/org/sonar/core/purge/PurgeMapper.xml @@ -169,10 +169,22 @@ 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> diff --git a/sonar-core/src/test/java/org/sonar/core/purge/PurgeDaoTest.java b/sonar-core/src/test/java/org/sonar/core/purge/PurgeDaoTest.java index 5d4e07a847a..df17a128b8f 100644 --- a/sonar-core/src/test/java/org/sonar/core/purge/PurgeDaoTest.java +++ b/sonar-core/src/test/java/org/sonar/core/purge/PurgeDaoTest.java @@ -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> { diff --git a/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/shouldDeleteProject.xml b/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/shouldDeleteProject.xml index 88e87f2583b..472874f6dee 100644 --- a/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/shouldDeleteProject.xml +++ b/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/shouldDeleteProject.xml @@ -16,6 +16,19 @@ 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" |