All pastes #979263 Raw Edit

Untitled

public text v1 · immutable
·published 2008-04-10 05:59 UTC
rendered paste body
class LoadLshwOutput < ActiveRecord::Migration
  def self.up
    for report in Report.find(:all)
      file = "/var/www/fgss/lshw_xml/#{report.system_id.to_s}-#{report.role_id.to_s}-#{report.created_at.to_time.strftime("%Y-%m-%d-%H%M")}.xml" 
      if File.exist?(file)
        fd = File.open(file, 'r')
        report.lshw_output = fd.read
        fd.close
        report.save
      else
      end
    end
  end

  def self.down
    raise "I DONT CARE"
  end
end
=begin
www-data@rocky:~/fgss$ rake db:migrate
(in /var/www/fgss)
== 2 LoadLshwOutput: migrating ================================================
== 2 LoadLshwOutput: migrated (34.7886s) =======================================

www-data@rocky:~/fgss$
=end
=begin
fgss=# SELECT * FROM reports WHERE lshw_output IS NOT NULL;
 id | system_id | contact_id | role_id | lshw_output | lock_version | updated_at | created_at | created_by | updated_by | old_id | notes | type_id | os | filename
----+-----------+------------+---------+-------------+--------------+------------+------------+------------+------------+--------+-------+---------+----+----------
(0 rows)

fgss=#
=end