Sha256: e06e6703df8a0e55614843887eeae22924cf72e37a97389f90d38b51b250b90b
Contents?: true
Size: 1018 Bytes
Versions: 15
Compression:
Stored size: 1018 Bytes
Contents
class ActivitiesToVersions < ActiveRecord::Migration def up events = { 'created' => 'create', 'viewed' => 'view', 'updated' => 'update', 'deleted' => 'destroy', 'rejected' => 'reject', 'won' => 'won', 'completed' => 'complete', 'reassigned' => 'reassign', 'rescheduled' => 'reschedule' } activities = connection.select_all 'SELECT * FROM activities' activities.each do |activity| # commented and email activities don't translate well so ignore them if event = events[activity['action']] attributes = { :item_id => activity['subject_id'], :item_type => activity['subject_type'], :whodunnit => activity['user_id'], :event => event, :created_at => activity['created_at'] } version = Version.new attributes.each {|k, v| version.send("#{k}=", v)} version.save! end end end def down end end
Version data entries
15 entries across 15 versions & 1 rubygems