Ruby 无法回滚迁移。StandardError:发生错误,所有后续迁移均已取消
我刚刚迁移了一个文件,但在def-down中,我忘了按相反的顺序放置列。迁移后架构已更新,但我无法回滚。我尝试在迁移文件中反转列顺序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
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