beast rev 2066
[beast-modified.git] / db / migrate / 026_change_sticky_to_integer.rb
blobf7dc272336a8e427e90451a538223e58f0ecd15d
1 class ChangeStickyToInteger < ActiveRecord::Migration
2   class Topic < ActiveRecord::Base; end
3   def self.up
4     sticky_topics = Topic.find_all_by_sticky(true).collect &:id
5     change_column :topics, :sticky, :integer, :default => 0
6     Topic.update_all 'sticky=1', ['id in (?)', sticky_topics]
7   end
9   def self.down
10     change_column :topics, :sticky, :boolean, :default => false
11   end
12 end