summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorPeter Kozak <spag@golwen.net>2013-02-25 11:43:54 -0500
committerPeter Kozak <spag@golwen.net>2013-02-25 11:43:54 -0500
commit3ce588cd21c15acc0f7c66339d68e7651a798cc6 (patch)
treeb8da80397cb1d66d79272b3125140d7805d1688a /db
parentfd07b7b85d2d40d7d2999c2899cc890eda2095fd (diff)
destinationable columns added../db/migrate/20130225091200_add_destinationable_to_call_forward.rb
Diffstat (limited to 'db')
-rw-r--r--db/migrate/20130225091200_add_destinationable_to_call_forward.rb21
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