aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-server/src
diff options
context:
space:
mode:
authorsimonbrandhof <simon.brandhof@gmail.com>2010-12-21 16:24:04 +0000
committersimonbrandhof <simon.brandhof@gmail.com>2010-12-21 16:24:04 +0000
commit13d356806a18cbcf080aa784765a07fa310b29d8 (patch)
tree1b54dd90b6b512df50d479a67132bc3fbb66c2fd /sonar-server/src
parentd538be810f6d83fbbb4b2e4de2a4da08e6919576 (diff)
downloadsonarqube-13d356806a18cbcf080aa784765a07fa310b29d8.tar.gz
sonarqube-13d356806a18cbcf080aa784765a07fa310b29d8.zip
fix migration on large databases
Diffstat (limited to 'sonar-server/src')
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/db/migrate/162_delete_iso_rule_categories.rb6
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/db/migrate/164_delete_measures_on_violations_and_priority.rb6
2 files changed, 8 insertions, 4 deletions
diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/162_delete_iso_rule_categories.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/162_delete_iso_rule_categories.rb
index f4253c74b59..2b426cb6520 100644
--- a/sonar-server/src/main/webapp/WEB-INF/db/migrate/162_delete_iso_rule_categories.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/db/migrate/162_delete_iso_rule_categories.rb
@@ -39,7 +39,9 @@ class DeleteIsoRuleCategories < ActiveRecord::Migration
end
def self.delete_measures_on_iso_category
- puts "If the following step fails, please execute the SQL request 'DELETE FROM PROJECT_MEASURES WHERE RULE_ID IS NULL AND RULES_CATEGORY_ID IS NOT NULL' and restart Sonar."
- ProjectMeasure.delete_all('rule_id is null and rules_category_id is not null')
+ ids=ProjectMeasure.connection.select_values("SELECT ID FROM PROJECT_MEASURES WHERE RULE_ID IS NULL AND RULES_CATEGORY_ID IS NOT NULL")
+ ids.in_groups_of(900, false) do |group|
+ ProjectMeasure.delete(group.map{|id| id.to_i}) unless group.empty?
+ end
end
end
diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/164_delete_measures_on_violations_and_priority.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/164_delete_measures_on_violations_and_priority.rb
index b3178dfc8bb..56f2febf0e5 100644
--- a/sonar-server/src/main/webapp/WEB-INF/db/migrate/164_delete_measures_on_violations_and_priority.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/db/migrate/164_delete_measures_on_violations_and_priority.rb
@@ -24,8 +24,10 @@
class DeleteMeasuresOnViolationsAndPriority < ActiveRecord::Migration
def self.up
- puts "If the following step fails, please execute the SQL request 'DELETE FROM PROJECT_MEASURES WHERE RULE_ID IS NULL AND RULE_PRIORITY IS NOT NULL' and restart Sonar."
- ProjectMeasure.delete_all('rule_id is null and rule_priority is not null')
+ ids=ProjectMeasure.connection.select_values("SELECT ID FROM PROJECT_MEASURES WHERE RULE_ID IS NULL AND RULE_PRIORITY IS NOT NULL")
+ ids.in_groups_of(900, false) do |group|
+ ProjectMeasure.delete(group.map{|id| id.to_i}) unless group.empty?
+ end
end
end