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
+3 -2
View File
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20151219225720) do
ActiveRecord::Schema.define(version: 20151230021120) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -66,11 +66,12 @@ ActiveRecord::Schema.define(version: 20151219225720) do
t.boolean "bike_fixed"
t.integer "number_of_calls"
t.boolean "application_voided"
t.date "pickup_date"
t.date "pickup_date_bkp"
t.string "volunteer_at_pickup"
t.float "weight"
t.float "height"
t.datetime "application_date"
t.datetime "pickup_date"
end
add_index "clients", ["agency_id"], name: "index_clients_on_agency_id", using: :btree