]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-3594 Ignore unknown filters during migration to 3.1
authorDavid Gageot <david@gageot.net>
Fri, 29 Jun 2012 14:53:50 +0000 (16:53 +0200)
committerDavid Gageot <david@gageot.net>
Fri, 29 Jun 2012 14:53:50 +0000 (16:53 +0200)
Because we activate a Global Dashboard for each Active Filter, we need
to ignore those pointing to a deleted Filter.

sonar-server/src/main/webapp/WEB-INF/db/migrate/302_create_global_dashboards_for_filter.rb

index eb0cdbaa50d85f8f0110d706335e4f277da63e42..a7ddebd1602459807b256669c74b7f9b943f8533 100644 (file)
@@ -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