Bike!Bike! Website!
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

12 lines
283 B

class AddCityIdToLocation < ActiveRecord::Migration
def change
add_column :locations, :city_id, :integer
Location.all.each do |l|
city = City.search(([l.city, l.territory, l.country] - [nil, '']).join(', '))
l.city_id = city.id
l.save!
end
end
end