Reputation: 836
I am getting the following error while running rake db:migrate:
StandardError: An error has occurred, this and all later migrations canceled:
Couldn't find Report with 'id'=all [WHERE "reports"."deleted_at" IS NULL]
Theseare my 2 migration files:
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.
Please tell me how can I fix this?
Upvotes: 0
Views: 606
Reputation: 44380
Look at the documention for the method find
for version > 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]). If no record can be found for all of the listed ids, then RecordNotFound will be raised. If the primary key is an integer, find by id coerces its arguments using to_i.
An for version < 4.0:
Find operates with four different retrieval approaches:
Upvotes: 2