class AddDocRefToPDocuments < ActiveRecord::Migration
  def change
    add_column :p_documents, :doc_ref_id, :integer
    add_column :p_documents, :echeance_date, :date
    add_column :p_documents, :avoir_text, :text
    add_column :p_documents, :doc_ref_number, :string
    
    add_column :p_documents, :cache_fdp, :decimal, :precision => 13, :scale => 2
    
    
    
    PDocument.all.each do |pd|
      pd.cache_fdp = PSheetLine.frais_de_port(pd.p_sheet_lines)
      pd.save
    end
  end
end
