diff options
author | Stefan Wintermeyer <stefan.wintermeyer@amooma.de> | 2013-02-27 12:22:29 +0100 |
---|---|---|
committer | Stefan Wintermeyer <stefan.wintermeyer@amooma.de> | 2013-02-27 12:22:29 +0100 |
commit | 67c1a0a951403a546250ea860a3e3d199cae2fce (patch) | |
tree | f86ec6cedf081a1a57005eca1661e9bead34e4de /db/migrate/20130225091200_add_destinationable_to_call_forward.rb | |
parent | 5d8ce5f4775ac8bc5f523964e6e36f63ff3c4683 (diff) | |
parent | 211f558a86ae30cdd5b392ab1376e1393f97e22c (diff) |
Merge branch 'develop'5.1-beta6
Diffstat (limited to 'db/migrate/20130225091200_add_destinationable_to_call_forward.rb')
-rw-r--r-- | db/migrate/20130225091200_add_destinationable_to_call_forward.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/db/migrate/20130225091200_add_destinationable_to_call_forward.rb b/db/migrate/20130225091200_add_destinationable_to_call_forward.rb new file mode 100644 index 0000000..89e4b3b --- /dev/null +++ b/db/migrate/20130225091200_add_destinationable_to_call_forward.rb @@ -0,0 +1,21 @@ +class AddDestinationableToCallForward < ActiveRecord::Migration + def up + add_column :call_forwards, :destinationable_type, :string + add_column :call_forwards, :destinationable_id, :integer + + CallForward.all.each do |call_forward| + call_forward.update_attributes(:destinationable_type => call_forward.call_forwardable_type, :destinationable_id => call_forward.call_forwardable_id, :call_forwardable_type => 'PhoneNumber', :call_forwardable_id => call_forward.phone_number_id ) + end + + remove_column :call_forwards, :phone_number_id + end + + def down + add_column :call_forwards, :phone_number_id, :integer + CallForward.where(:call_forwardable_type => 'PhoneNumber').each do |call_forward| + call_forward.update_attributes(:phone_number_id => call_forward.call_forwardable_id, :call_forwardable_type => call_forward.destinationable_type, :call_forwardable_id => call_forward.destinationable_id) + end + remove_column :call_forwards, :destinationable_type + remove_column :call_forwards, :destinationable_id + end +end |