]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-1927 really fix database migration
authorDavid Gageot <david@gageot.net>
Mon, 7 May 2012 07:56:20 +0000 (09:56 +0200)
committerDavid Gageot <david@gageot.net>
Mon, 7 May 2012 08:41:49 +0000 (10:41 +0200)
sonar-server/src/main/webapp/WEB-INF/app/models/dashboard.rb
sonar-server/src/main/webapp/WEB-INF/db/migrate/300_add_global_to_dashboards.rb

index 1dfdc522b579eea5df6bf998a79bbcd5d952f997..3562e5232efd3991de8695a40df00982be0f8fae 100644 (file)
@@ -30,6 +30,7 @@ class Dashboard < ActiveRecord::Base
   validates_length_of :description, :maximum => 1000, :allow_blank => true, :allow_nil => true
   validates_length_of :column_layout, :maximum => 20, :allow_blank => false, :allow_nil => false
   validates_uniqueness_of :name, :scope => :user_id
+  validates_inclusion_of :is_global, :in => [true, false]
 
   before_destroy :check_not_default_before_destroy
 
index 1b87e6c7026830ee768965b294f32e6f6479dd71..7b90a52dde080455e10352b3cea44a2f6a5deb3f 100644 (file)
@@ -24,7 +24,8 @@
 class AddGlobalToDashboards < ActiveRecord::Migration
 
   def self.up
-    add_column 'dashboards', 'is_global', :boolean, :null => false
+    add_column 'dashboards', 'is_global', :boolean
+    Dashboard.update_all(Dashboard.sanitize_sql_for_assignment({:is_global => false}))
   end
 
 end