Cant rollback a migration. StandardError: An error has occurred, all later migrations canceled

Cant rollback a migration. StandardError: An error has occurred, all later migrations canceled

我刚刚迁移了一个文件,但在 def down 中我忘记了将列倒序放置。迁移后架构已更新,但我无法回滚。我尝试颠倒迁移文件中的列顺序。

class AddAttachmentPictureToHotels < ActiveRecord::Migration[5.2]
  def self.up
    change_table :hotels do |t|
      t.attachment :picture
      t.float :latitude
      t.float :longitude
      t.float :distance
    end
  end

  def self.down
    remove_attachment :hotels, :picture
    remove_float :hotels, :latitude
    remove_float :hotels, :longitude
    remove_float :hotels, :distance
  end
end

我的架构是这样的

  create_table "hotels", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
    t.string "name"
    t.datetime "created_at", null: false
    t.datetime "updated_at", null: false
    t.bigint "city_id"
    t.string "picture_file_name"
    t.string "picture_content_type"
    t.integer "picture_file_size"
    t.datetime "picture_updated_at"
    t.float "lattitude"
    t.float "longitude"
    t.float "distance"
    t.index ["city_id"], name: "index_hotels_on_city_id"
  end

如何回滚?

改成这样

  def self.down
    remove_column :hotels, :picture
    remove_column :hotels, :lattitude
    remove_column :hotels, :longitude
    remove_column :hotels, :distance
    remove_column :hotels, :picture_file_name
    remove_column :hotels, :picture_content_type
  end

旁注 lattitude 拼写错误,应为 latitude