class AddBillingToOrders < ActiveRecord::Migration
  def change
    add_column :orders, :bill_id, :integer
    add_column :orders, :bill_number, :string
    add_column :orders, :bill_at, :datetime
    add_column :orders, :demande_rbt, :boolean
    add_column :orders, :bill_token, :string
    
    Order.where(:payment_type_id => 2).order("paid_at ASC").each do |order|
      order.generate_bill
      order.save
    end
  end
end
