From 21fb9909437e0d67ea4fe6375cd86bfae31ec6c0 Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Tue, 9 Aug 2011 10:38:24 +0200 Subject: [PATCH] Fix migration of manual measures --- .../db/migrate/212_move_async_measures.rb | 22 +++++++++---------- 1 file 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 -- 2.39.5