Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby-on-rails-4/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby 无法回滚迁移。StandardError:发生错误,所有后续迁移均已取消_Ruby_Ruby On Rails 4 - Fatal编程技术网

Ruby 无法回滚迁移。StandardError:发生错误,所有后续迁移均已取消

Ruby 无法回滚迁移。StandardError:发生错误,所有后续迁移均已取消,ruby,ruby-on-rails-4,Ruby,Ruby On Rails 4,我刚刚迁移了一个文件,但在def-down中,我忘了按相反的顺序放置列。迁移后架构已更新,但我无法回滚。我尝试在迁移文件中反转列顺序 class AddAttachmentPictureToHotels < ActiveRecord::Migration[5.2] def self.up change_table :hotels do |t| t.attachment :picture t.float :latitude t.float :l

我刚刚迁移了一个文件,但在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
如何回滚它?

将其更改为此

  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(纬度)
latitude(纬度)

是我的错,我做了rake db:drop db:create db:migrate,在从迁移文件中删除列后,工作正常。但是谢谢
  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