mirror of
https://github.com/fspc/BikeShed-1.git
synced 2025-02-28 08:43:23 -05:00
Make migration robust to model changes
This commit is contained in:
parent
1075c1a5b3
commit
076a59ab45
@ -3,8 +3,7 @@ class AddModelToBike < ActiveRecord::Migration
|
||||
add_column :bikes, :model, :string
|
||||
change_column :bikes, :bike_model_id, :integer, :null => true
|
||||
Bike.all.each do |bike|
|
||||
bike.model = BikeModel.find_by_id(bike.bike_model_id).model
|
||||
bike.save
|
||||
bike.update_attribute(:model, BikeModel.find_by_id(bike['bike_model_id']).model )
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user