aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@gmail.com>2011-08-09 10:38:24 +0200
committerSimon Brandhof <simon.brandhof@gmail.com>2011-08-09 10:38:24 +0200
commit21fb9909437e0d67ea4fe6375cd86bfae31ec6c0 (patch)
tree5dad167fd7bac8135a06b95c428cae28202d6a11
parent254f2271ab9b6e99faf99e92bf5eb324e9dfbf8d (diff)
downloadsonarqube-21fb9909437e0d67ea4fe6375cd86bfae31ec6c0.tar.gz
sonarqube-21fb9909437e0d67ea4fe6375cd86bfae31ec6c0.zip
Fix migration of manual measures
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/db/migrate/212_move_async_measures.rb22
1 files changed, 11 insertions, 11 deletions
diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/212_move_async_measures.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/212_move_async_measures.rb
index d9caab90f1b..6b651a24e7d 100644
--- a/sonar-server/src/main/webapp/WEB-INF/db/migrate/212_move_async_measures.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/db/migrate/212_move_async_measures.rb
@@ -34,19 +34,19 @@ class MoveAsyncMeasures < ActiveRecord::Migration
end
def self.up
- deprecated_measures=AsyncMeasureSnapshot.find(:all, :include => 'measure')
-
+ deprecated_measures=AsyncMeasureSnapshot.find(:all, :include => 'measure', :conditions => 'snapshot_id is not null')
say_with_time "Moving #{deprecated_measures.size} measures" do
deprecated_measures.each do |dm|
- ManualMeasure.create(
- :resource_id => dm.project_id,
- :metric_id => dm.measure.metric_id,
- :value => dm.measure.value,
- :text_value => dm.measure.text_value,
- :created_at => dm.measure_date,
- :updated_at => dm.measure_date,
- :description => dm.measure.description
- )
+ if dm.measure && dm.project_id
+ ManualMeasure.create(
+ :resource_id => dm.project_id,
+ :metric_id => dm.measure.metric_id,
+ :value => dm.measure.value,
+ :text_value => dm.measure.text_value,
+ :created_at => dm.measure_date,
+ :updated_at => dm.measure_date,
+ :description => dm.measure.description)
+ end
end
end
end