【发布时间】:2019-07-17 11:50:38
【问题描述】:
我正在处理一个 Rails 5 项目,我已经在我的一些表中添加了各种列并创建了一个新表。这显然创建了一些迁移文件,我想恢复到某个迁移并删除此迁移后对架构进行的所有更改。我该怎么做?
Schema.rb:
ActiveRecord::Schema.define(version: 20180814220216) do
create_table "stores", force: :cascade do |t|
t.string "name"
t.string "address"
t.float "beer_cost"
t.text "facilities"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.float "latitude"
t.float "longitude"
t.boolean "toilet"
t.string "address_line2"
t.string "address_line3"
t.integer "user_id"
t.integer "toilet_id"
t.string "toilet_available"
end
create_table "toilets", force: :cascade do |t|
t.string "toilet_available"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
create_table "users", force: :cascade do |t|
t.string "email", default: "", null: false
t.string "encrypted_password", default: "", null: false
t.string "reset_password_token"
t.datetime "reset_password_sent_at"
t.datetime "remember_created_at"
t.integer "sign_in_count", default: 0, null: false
t.datetime "current_sign_in_at"
t.datetime "last_sign_in_at"
t.string "current_sign_in_ip"
t.string "last_sign_in_ip"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["email"], name: "index_users_on_email", unique: true
t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
end
end
运行后输出rails db:migrate:status
Status Migration ID Migration Name
--------------------------------------------------
up 20180610144440 Create stores
up 20180611145310 Change datatype beer cost
up 20180611150425 Delete cig cost column
up 20180611231832 Add longitude and latitude
up 20180612194032 Add toilets column
up 20180614125348 Add address line2 column
up 20180614133234 Add address line3 column
up 20180625201708 Devise create users
up 20180625235156 Add user id to stores
up 20180626124327 ********** NO FILE **********
up 20180626124742 ********** NO FILE **********
up 20180627115344 ********** NO FILE **********
up 20180627115710 ********** NO FILE **********
up 20180810102513 ********** NO FILE **********
up 20180811094301 ********** NO FILE **********
up 20180814220216 ********** NO FILE **********
【问题讨论】:
标签: ruby-on-rails ruby activerecord