2012-01-05 03:15:48 +08:00
|
|
|
class FixSisCommunicationChannels < ActiveRecord::Migration
|
2013-10-26 06:12:54 +08:00
|
|
|
disable_ddl_transaction!
|
2012-01-05 03:15:48 +08:00
|
|
|
|
2012-02-03 02:29:20 +08:00
|
|
|
def self.up
|
2012-01-05 03:15:48 +08:00
|
|
|
begin
|
2013-03-19 23:48:47 +08:00
|
|
|
pseudonym_ids = Pseudonym.joins(:sis_communication_channel).where("pseudonyms.user_id<>communication_channels.user_id").limit(1000).pluck(:id)
|
|
|
|
Pseudonym.where(:id => pseudonym_ids).update_all(:sis_communication_channel_id => nil)
|
2012-01-05 03:15:48 +08:00
|
|
|
sleep 1
|
|
|
|
end until pseudonym_ids.empty?
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.down
|
|
|
|
end
|
|
|
|
end
|