Sha256: 6a16626698ab16b9a33fc95d879d736c6c85711c14920ba2a1dcb9290da880ad

Contents?: true

Size: 406 Bytes

Versions: 31

Compression:

Stored size: 406 Bytes

Contents

class AddPriceToLineItem < ActiveRecord::Migration
  def up
    add_column :line_items, :price, :decimal, :null => false, :default => 0.0
    
    change_table(:line_items) do |t|
      t.timestamps
    end

    Piggybak::LineItem.all.each do |line_item|
      line_item.update_attribute(:price, line_item.total/line_item.quantity)
    end
  end

  def down
    remove_column :line_items, :price
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
piggybak-0.6.34 db/migrate/20120627144001_add_price_to_line_item.rb
piggybak-0.7.4 db/migrate/20120627144001_add_price_to_line_item.rb
piggybak-0.7.3 db/migrate/20120627144001_add_price_to_line_item.rb
piggybak-0.7.2 db/migrate/20120627144001_add_price_to_line_item.rb
piggybak-0.7.1 db/migrate/20120627144001_add_price_to_line_item.rb
piggybak-0.7.0 db/migrate/20120627144001_add_price_to_line_item.rb
piggybak-0.6.33 db/migrate/20120627144001_add_price_to_line_item.rb
piggybak-0.6.32 db/migrate/20120627144001_add_price_to_line_item.rb
piggybak-0.6.31 db/migrate/20120627144001_add_price_to_line_item.rb
piggybak-0.6.30 db/migrate/20120627144001_add_price_to_line_item.rb
piggybak-0.6.29 db/migrate/20120627144001_add_price_to_line_item.rb
piggybak-0.6.28 db/migrate/20120627144001_add_price_to_line_item.rb
piggybak-0.6.27 db/migrate/20120627144001_add_price_to_line_item.rb
piggybak-0.6.26 db/migrate/20120627144001_add_price_to_line_item.rb
piggybak-0.6.25 db/migrate/20120627144001_add_price_to_line_item.rb
piggybak-0.6.24 db/migrate/20120627144001_add_price_to_line_item.rb
piggybak-0.6.23 db/migrate/20120627144001_add_price_to_line_item.rb
piggybak-0.6.22 db/migrate/20120627144001_add_price_to_line_item.rb
piggybak-0.6.21 db/migrate/20120627144001_add_price_to_line_item.rb
piggybak-0.6.20 db/migrate/20120627144001_add_price_to_line_item.rb