2012-02-14 16:05:41 +00:00
|
|
|
class ChangeSubscribeableIdToDecimal < ActiveRecord::Migration
|
|
|
|
def up
|
2014-01-21 04:51:49 +00:00
|
|
|
add_column :subscribes, :subscribeable_id_tmp, :decimal, precision: 50, scale: 0
|
2012-02-14 16:05:41 +00:00
|
|
|
Subscribe.reset_column_information
|
|
|
|
Subscribe.all.each {|c| c.update_column :subscribeable_id_tmp, (c.subscribeable_type == 'Grit::Commit' ? c.subscribeable_id.hex : c.subscribeable_id.to_i)}
|
|
|
|
remove_column :subscribes, :subscribeable_id
|
|
|
|
rename_column :subscribes, :subscribeable_id_tmp, :subscribeable_id
|
|
|
|
end
|
|
|
|
|
|
|
|
def down
|
|
|
|
add_column :subscribes, :subscribeable_id_tmp, :string
|
|
|
|
Subscribe.reset_column_information
|
|
|
|
Subscribe.all.each {|c| c.update_column :subscribeable_id_tmp, (c.subscribeable_type == 'Grit::Commit' ? c.subscribeable_id.to_s(16) : c.subscribeable_id.to_s)}
|
|
|
|
remove_column :subscribes, :subscribeable_id
|
|
|
|
rename_column :subscribes, :subscribeable_id_tmp, :subscribeable_id
|
|
|
|
end
|
|
|
|
end
|