I am fixing an error I made in naming a column type in my database table from an integer to datetime. However, I get a pending migration error after I run rake db:migrate after writing the following. When I added the new migration via rails g MigrateDeliveryTimeDates, no new file was generated under db/migrate so I created it manually. The error reads:
An error has occurred, this and all later migrations canceled:
undefined method `deliverytime_temp'
Here is my db/migrate file:
class ChangeColumnDeliveryTime < ActiveRecord::Migration
def change
rename_column(:deliveries, :deliverytime, :deliverytime_temp)
add_column(:deliveries, :deliverytime, :datetime)
end
end
Here is the migration I added (rails g migration ChangeColumnDeliveryTime):
class ChangeColumnDeliveryTime < ActiveRecord::Migration
def change
change_column(:deliveries, :deliverytime, :datetime)
end
end
Here is my db schema:
ActiveRecord::Schema.define(version: 20160216220012) do
create_table "deliveries", force: :cascade do |t|
t.string "name"
t.string "deliveryaddress"
t.integer "deliverytime"
t.string "notes"
t.integer "order_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
add_index "deliveries", ["order_id"], name: "index_deliveries_on_order_id"
create_table "orders", force: :cascade do |t|
t.datetime "date"
t.string "name"
t.string "pickup"
t.datetime "pickuptime"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
end
How can I resolve this error?
Aucun commentaire:
Enregistrer un commentaire