2012-01-26 05:12:59 +08:00
|
|
|
class ConversationDataUpdate < ActiveRecord::Migration
|
2012-04-25 02:23:44 +08:00
|
|
|
tag :postdeploy
|
|
|
|
|
2012-01-26 05:12:59 +08:00
|
|
|
def self.up
|
2012-02-08 05:33:23 +08:00
|
|
|
SubmissionComment.connection.select_all("SELECT DISTINCT submission_id AS id FROM submission_comments WHERE NOT hidden").
|
2012-01-26 05:12:59 +08:00
|
|
|
map{ |r| r["id"] }.each_slice(1000) do |ids|
|
|
|
|
Submission.send_later_if_production_enqueue_args(:batch_migrate_conversations!, {
|
|
|
|
:priority => Delayed::LOWER_PRIORITY,
|
|
|
|
:max_attempts => 1,
|
|
|
|
:strand => "migrate_submission_conversations"
|
|
|
|
}, ids)
|
|
|
|
end
|
|
|
|
|
|
|
|
Conversation.connection.select_all("SELECT id FROM conversations").
|
|
|
|
map{ |r| r["id"] }.each_slice(1000) do |ids|
|
|
|
|
Conversation.send_later_if_production_enqueue_args(:batch_migrate_context_tags!, {
|
|
|
|
:priority => Delayed::LOWER_PRIORITY,
|
|
|
|
:max_attempts => 1,
|
|
|
|
:strand => "migrate_conversation_context_tags"
|
|
|
|
}, ids)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.down
|
|
|
|
raise ActiveRecord::IrreversibleMigration
|
|
|
|
end
|
|
|
|
end
|