]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-5007 fix db migrations 538 and 539
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Fri, 23 May 2014 15:51:15 +0000 (17:51 +0200)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Fri, 23 May 2014 16:19:31 +0000 (18:19 +0200)
sonar-server/src/main/webapp/WEB-INF/db/migrate/538_add_dates_to_active_rules_table.rb
sonar-server/src/main/webapp/WEB-INF/db/migrate/539_insert_active_rule_dates.rb

index 6333eac13635126e28bdffee4e0dccdbd46e16ee..bb363507ebb8c7f6e7568ae2c45b671ae0116602 100644 (file)
 #
 class AddDatesToActiveRulesTable < ActiveRecord::Migration
 
-  class ActiveRule < ActiveRecord::Base
-  end
-
   def self.up
-    now = Time.now
-    ActiveRule.find(:all).each do |active_rule|
-      active_rule.created_at=now
-      active_rule.updated_at=now
-      active_rule.save!
+    def self.up
+      add_column 'active_rules', :created_at, :datetime, :null => true
+      add_column 'active_rules', :updated_at, :datetime, :null => true
     end
   end
-
 end
 
index 72ce86929c3370d45be70a4e40da49f2dde9c00b..1945bca7e61c3eb7748a518b98f8338261359473 100644 (file)
 #
 class InsertActiveRuleDates < ActiveRecord::Migration
 
-  def self.up
+  class ActiveRule < ActiveRecord::Base
+  end
 
+  def self.up
+    now = Time.now
+    ActiveRule.find(:all).each do |active_rule|
+      active_rule.created_at=now
+      active_rule.updated_at=now
+      active_rule.save!
+    end
   end
 
 end