Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save tbuehlmann/02327d8ca1f249175d5ced0d73ce288b to your computer and use it in GitHub Desktop.
Save tbuehlmann/02327d8ca1f249175d5ced0d73ce288b to your computer and use it in GitHub Desktop.
class AddPriceToLineItem < ActiveRecord::Migration[5.0]
def change
add_column :line_items, :price, :decimal
LineItem.includes(:product).find_each do |li|
li.update(price: li.product.price)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment