diff options
author | Simon Brandhof <simon.brandhof@gmail.com> | 2011-08-09 10:38:24 +0200 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@gmail.com> | 2011-08-09 10:38:24 +0200 |
commit | 21fb9909437e0d67ea4fe6375cd86bfae31ec6c0 (patch) | |
tree | 5dad167fd7bac8135a06b95c428cae28202d6a11 | |
parent | 254f2271ab9b6e99faf99e92bf5eb324e9dfbf8d (diff) | |
download | sonarqube-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.rb | 22 |
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 |