[英]Couldn't find table with 'id'=all Migration error in Rails 4.2.6
I am getting the following error while running rake db:migrate: 运行rake db:migrate时出现以下错误:
StandardError: An error has occurred, this and all later migrations canceled: StandardError:发生错误,此错误和所有后续迁移被取消:
Couldn't find Report with 'id'=all [WHERE "reports"."deleted_at" IS NULL] 找不到'id'= all [WHERE“ reports”。“ deleted_at” IS NULL]的报告
Theseare my 2 migration files: 这些是我的2个迁移文件:
Class AddColorToReports < ActiveRecord::Migration
def self.up
add_column :reports, :button_color, :string
Report.find(:all).each do |r|
r.update_attribute(:color, r.top_stroke_color)
end
end
def self.down
remove_column :reports, :button_color
end
end
class AddDeletedAtToReport < ActiveRecord::Migration
def change
add_column :reports, :deleted_at, :datetime
end
end
The migrations are fine when running Rail 3.2 and 4.0, but here in 4.2.6, not working. 在运行Rail 3.2和4.0时,迁移很好,但是在4.2.6中无法正常工作。
Please tell me how can I fix this? 请告诉我该如何解决?
Look at the documention for the method find
for version > 4.0: 在文档中find
版本> 4.0的方法:
Find by id - This can either be a specific id (1), a list of ids (1, 5, 6), or an array of ids ([5, 6, 10]). 按ID查找-这可以是特定ID(1),ID列表(1、5、6)或ID数组([5、6、10])。 If no record can be found for all of the listed ids, then RecordNotFound will be raised. 如果找不到所有列出的ID的记录,则将引发RecordNotFound。 If the primary key is an integer, find by id coerces its arguments using to_i. 如果主键是整数,则按id查找使用to_i强制其参数。
An for version < 4.0: 版本低于4.0的:
Find operates with four different retrieval approaches: Find具有四种不同的检索方法:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.