diff options
author | Simon Brandhof <simon.brandhof@gmail.com> | 2012-11-05 14:46:01 +0100 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@gmail.com> | 2012-11-05 14:46:01 +0100 |
commit | 34f1314f92740fbdcd8b79cb3c807405f08fad08 (patch) | |
tree | 87d8011807831c623af6c6eef8843f8bc1400674 | |
parent | 467236bf670ad9f7a6806ee0fe13c01ca1f8f4d3 (diff) | |
download | sonarqube-34f1314f92740fbdcd8b79cb3c807405f08fad08.tar.gz sonarqube-34f1314f92740fbdcd8b79cb3c807405f08fad08.zip |
SONAR-3929 Database upgrade fails
-rw-r--r-- | sonar-server/src/main/webapp/WEB-INF/db/migrate/331_remove_projects_profile_id.rb | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/331_remove_projects_profile_id.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/331_remove_projects_profile_id.rb index 68fc65062e4..abe99ac17c9 100644 --- a/sonar-server/src/main/webapp/WEB-INF/db/migrate/331_remove_projects_profile_id.rb +++ b/sonar-server/src/main/webapp/WEB-INF/db/migrate/331_remove_projects_profile_id.rb @@ -28,16 +28,21 @@ class RemoveProjectsProfileId < ActiveRecord::Migration end class Project < ActiveRecord::Base - belongs_to :profile + end class Property < ActiveRecord::Base end def self.up - projects=Project.find(:all, :conditions => ['profile_id is not null and copy_resource_id is null'], :include => :profile) - projects.each do |project| - Property.create(:prop_key => "sonar.profile.#{project.profile.language}", :text_value => project.profile.name, :resource_id => project.id) + projects=Project.find(:all, :conditions => ['profile_id is not null and copy_resource_id is null']) + say_with_time "Processing #{projects.size} projects..." do + projects.each do |project| + profile = Profile.find(:first, :conditions => ['id=?', project.profile_id]) + if profile + Property.create(:prop_key => "sonar.profile.#{profile.language}", :text_value => profile.name, :resource_id => project.id) + end + end end remove_column('projects', 'profile_id') end |