lk | changes type of date stored for client pickup

This commit is contained in:
Louis Knapp
2015-12-29 20:19:25 -06:00
parent 3852c85432
commit a8c8f4b3d8
5 changed files with 31 additions and 6 deletions
@@ -0,0 +1,17 @@
class ChangePickupDateToDateTime < ActiveRecord::Migration
def up
add_column :clients, :pickup_datetime, :datetime
Client.all.to_a.each{ |client|
if client.pickup_date
client.update_attribute(:pickup_datetime, client.pickup_date)
end
}
rename_column :clients, :pickup_date, :pickup_date_bkp
rename_column :clients, :pickup_datetime, :pickup_date
end
def down
remove_column :clients, :pickup_date
rename_column :clients, :pickup_date_bkp, :pickup_date
end
end