*/
static final String[] TABLE_NAMES = {
"action_plans",
+ "action_plans_issues",
"action_plans_reviews",
"active_dashboards",
"active_rules",
*/
public class DatabaseVersion implements BatchComponent, ServerComponent {
- public static final int LAST_VERSION = 392;
+ public static final int LAST_VERSION = 393;
public static enum Status {
UP_TO_DATE, REQUIRES_UPGRADE, REQUIRES_DOWNGRADE, FRESH_INSTALL
session.commit();
profiler.stop();
+ profiler.start("deleteResourceIssueChanges (issue_changes)");
+ for (Long resourceId : resourceIds) {
+ purgeMapper.deleteResourceIssueChanges(resourceId);
+ }
+ session.commit();
+ profiler.stop();
+
+ profiler.start("deleteResourceActionPlansIssues (action_plans_issues)");
+ for (Long resourceId : resourceIds) {
+ purgeMapper.deleteResourceActionPlansIssues(resourceId);
+ }
+ session.commit();
+ profiler.stop();
+
+ profiler.start("deleteResourceIssues (issues)");
+ for (Long resourceId : resourceIds) {
+ purgeMapper.deleteResourceIssues(resourceId);
+ }
+ session.commit();
+ profiler.stop();
+
profiler.start("deleteResourceActionPlans (action_plans)");
for (Long resourceId : resourceIds) {
purgeMapper.deleteResourceActionPlans(resourceId);
void deleteResourceActionPlansReviews(long resourceId);
void deleteSnapshotData(long snapshotId);
+
+ void deleteResourceActionPlansIssues(long resourceId);
+
+ void deleteResourceIssueChanges(long resourceId);
+
+ void deleteResourceIssues(long resourceId);
+
}
INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('390');
INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('391');
INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('392');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('393');
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;
"UPDATED_AT" TIMESTAMP,
);
+CREATE TABLE "ACTION_PLANS_ISSUES" (
+ "ACTION_PLAN_ID" INTEGER,
+ "ISSUE_ID" INTEGER
+);
+
CREATE TABLE "SNAPSHOT_DATA" (
"ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
"SNAPSHOT_ID" INTEGER,
CREATE INDEX "ISSUES_RESOURCE_ID" ON "ISSUES" ("RESOURCE_ID");
+CREATE INDEX "INDEX_ACTION_PLANS_ISSUES_ON_ACTION_PLAN_ID" ON "ACTION_PLANS_ISSUES" ("ACTION_PLAN_ID");
+
+CREATE INDEX "INDEX_ACTION_PLANS_ISSUES_ON_ISSUE_ID" ON "ACTION_PLANS_ISSUES" ("ISSUE_ID");
+
--CREATE INDEX "ISSUES_RULE_ID" ON "ISSUES" ("RULE_ID");
--CREATE INDEX "SNAPSHOT_DATA_SNAPSHOT_ID" ON "SNAPSHOT_DATA" ("SNAPSHOT_ID");
delete apr from action_plans_reviews as apr, action_plans as ap where ap.id=apr.action_plan_id and ap.project_id=#{id}
</delete>
+ <delete id="deleteResourceActionPlansIssues" parameterType="long">
+ delete from action_plans_issues api where exists (select * from action_plans ap where ap.id=api.action_plan_id and ap.project_id=#{id})
+ </delete>
+
+ <delete id="deleteResourceIssueChanges" parameterType="long">
+ delete from issue_changes ic where exists (select * from issues i where ic.issue_key=i.kee and i.resource_id=#{id})
+ </delete>
+
+ <delete id="deleteResourceIssues" parameterType="long">
+ delete from issues where resource_id=#{id}
+ </delete>
+
</mapper>
} finally {
MyBatis.closeQuietly(session);
}
- assertEmptyTables("projects", "snapshots", "events", "reviews", "review_comments", "authors");
+ assertEmptyTables("projects", "snapshots", "events", "reviews", "review_comments", "issues", "issue_changes", "authors");
}
}
public void shouldDeleteProject() {
setupData("shouldDeleteProject");
dao.deleteResourceTree(1L);
- assertEmptyTables("projects", "snapshots", "action_plans", "action_plans_reviews", "reviews", "review_comments");
+ assertEmptyTables("projects", "snapshots", "action_plans", "action_plans_reviews", "reviews", "review_comments", "issues", "issue_changes", "action_plans_issues");
}
static final class SnapshotMatcher extends BaseMatcher<PurgeableSnapshotDto> {
<review_comments id="1" created_at="[null]" updated_at="[null]" review_id="1" user_id="1223" review_text="abc"/>
+ <issues id="1" kee="ABCDE" resource_id="1" status="CLOSED" resolution="[null]" created_at="[null]" line="200" severity="BLOCKER"
+ user_login="perceval" assignee_login="arthur" rule_id="500" manual_issue="[true]" manual_severity="[false]" description="[null]"/>
+
+ <issue_changes id="1" issue_key="ABCDE" created_at="[null]" updated_at="[null]" user_login="admin" message="abc"/>
+
<authors id="1" person_id="1" login="tartanpion" created_at="[null]" updated_at="[null]" />
<authors id="2" person_id="1" login="fanfoue" created_at="[null]" updated_at="[null]" />
</dataset>
\ No newline at end of file
<action_plans_reviews action_plan_id="1" review_id="250" />
+ <action_plans_issues action_plan_id="1" issue_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]"/>
<review_comments id="1" created_at="[null]" updated_at="[null]" review_id="2" user_id="1223" review_text="abc"/>
+ <issues id="1" kee="ABCDE" resource_id="1" status="CLOSED" resolution="[null]" created_at="[null]" line="200" severity="BLOCKER"
+ user_login="perceval" assignee_login="arthur" rule_id="500" manual_issue="[true]" manual_severity="[false]" description="[null]"/>
+
+ <issues id="2" kee="ABCDF" resource_id="1" status="CLOSED" resolution="[null]" created_at="[null]" line="200" severity="BLOCKER"
+ user_login="perceval" assignee_login="arthur" rule_id="500" manual_issue="[true]" manual_severity="[false]" description="[null]"/>
+
+ <issue_changes id="1" issue_key="ABCDF" created_at="[null]" updated_at="[null]" user_login="admin" message="abc"/>
+
<!-- modules -->
<projects id="2" enabled="[true]" root_id="1"
long_name="[null]" scope="PRJ" qualifier="BRC" kee="module1" name="module1"
--- /dev/null
+#
+# Sonar, entreprise quality control tool.
+# Copyright (C) 2008-2013 SonarSource
+# mailto:contact AT sonarsource DOT com
+#
+# SonarQube is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 3 of the License, or (at your option) any later version.
+#
+# SonarQube is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+
+#
+# Sonar 3.6
+#
+class CreateActionPlansIssues < ActiveRecord::Migration
+
+ def self.up
+ create_table :action_plans_issues, :id => false do |t|
+ t.integer :action_plan_id
+ t.integer :issue_id
+ end
+
+ add_index "action_plans_issues", "action_plan_id", :name => 'I_ACT_PLA_ISSUE_ACT_PLA_ID'
+ add_index "action_plans_issues", "issue_id", :name => 'I_ACT_PLA_ISSUE_ISSUE_ID'
+ end
+
+end
+