# -*- coding: utf-8 -*-
class AddComTroubleToReports < ActiveRecord::Migration
  def self.up
    add_column :reports, :com_trouble, :text
    rs=Report.ams.find(:all, :conditions =>"com_imperfection is not null AND DATE(date) > '2016-08-02' AND com_imperfection != ' ' AND status != 1")
    for r in rs do
      tr=r.com_imperfection
      r.update_attributes(:com_trouble => tr, :com_imperfection => '')
    end
  end

  def self.down
    remove_column :reports, :com_trouble
  end
end
