From 8a43d9562675bc71fe07d810faa890a853ca2552 Mon Sep 17 00:00:00 2001 From: David Gageot Date: Fri, 29 Jun 2012 16:53:50 +0200 Subject: [PATCH] SONAR-3594 Ignore unknown filters during migration to 3.1 Because we activate a Global Dashboard for each Active Filter, we need to ignore those pointing to a deleted Filter. --- .../302_create_global_dashboards_for_filter.rb | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/sonar-server/src/main/webapp/WEB-INF/db/migrate/302_create_global_dashboards_for_filter.rb b/sonar-server/src/main/webapp/WEB-INF/db/migrate/302_create_global_dashboards_for_filter.rb index eb0cdbaa50d..a7ddebd1602 100644 --- a/sonar-server/src/main/webapp/WEB-INF/db/migrate/302_create_global_dashboards_for_filter.rb +++ b/sonar-server/src/main/webapp/WEB-INF/db/migrate/302_create_global_dashboards_for_filter.rb @@ -78,14 +78,15 @@ class CreateGlobalDashboardsForFilter < ActiveRecord::Migration def self.activate_dashboards(dashboard_per_filter) ActiveFilter.find(:all).each do |activeFilter| - filter = Filter.find(activeFilter.filter_id) - - dashboard = dashboard_per_filter[filter.id] - - if !filter.favourites || activeFilter.user_id - ActiveDashboard.create(:dashboard_id => dashboard.id, - :user_id => activeFilter.user_id, - :order_index => activeFilter.order_index) + filter = Filter.find_by_id(activeFilter.filter_id) + if filter + dashboard = dashboard_per_filter[filter.id] + + if !filter.favourites || activeFilter.user_id + ActiveDashboard.create(:dashboard_id => dashboard.id, + :user_id => activeFilter.user_id, + :order_index => activeFilter.order_index) + end end end end -- 2.39.5