ref: master
db/migrate/20150216213259_create_profile_activity.rb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
class CreateProfileActivity < ActiveRecord::Migration def up ApplicationRecord.transaction do create_table :profile_activities do |t| t.integer :profile_id t.integer :activity_id t.string :activity_type t.timestamps end add_index :profile_activities, :profile_id add_index :profile_activities, [:activity_id, :activity_type] add_index :profile_activities, :activity_type Scrap.find_each batch_size: 50 do |scrap| scrap.send :create_activity end ActionTracker::Record.find_each batch_size: 50 do |action_tracker| action_tracker.send :create_activity end end end def down drop_table :profile_activities end end |