The older slow migration now doesn't need to actually migrate data since this larger schema change and migration of ALL report data to the schema will do that part too.
Paired-with: Nick Lewis Signed-off-by: Matt Robinson <[email protected]> --- Local-branch: ticket/next/5543 db/migrate/20101109001012_add_status_to_reports.rb | 30 +------------------ 1 files changed, 2 insertions(+), 28 deletions(-) diff --git a/db/migrate/20101109001012_add_status_to_reports.rb b/db/migrate/20101109001012_add_status_to_reports.rb index 593c96e..d1fa276 100644 --- a/db/migrate/20101109001012_add_status_to_reports.rb +++ b/db/migrate/20101109001012_add_status_to_reports.rb @@ -1,44 +1,18 @@ require "#{RAILS_ROOT}/lib/progress_bar" class AddStatusToReports < ActiveRecord::Migration - class Report < ActiveRecord::Base - delegate :failed?, :changed?, :to => :report - serialize :report, Puppet::Transaction::Report - - def report - rep = read_attribute(:report) - rep.extend(ReportExtensions) unless rep.nil? or rep.is_a?(ReportExtensions) - rep - end - end - class Node < ActiveRecord::Base - belongs_to :last_report, :class_name => 'AddStatusToReports::Report' + belongs_to :last_report, :class_name => 'Report' end def self.up add_column :reports, :status, :string add_index :reports, [:time, :node_id, :status] - reports = Report.all - pbar = ProgressBar.new("Migrating Reports:", reports.size, STDOUT) - reports.each do |report| - report.status = report.failed? ? 'failed' : report.changed? ? 'changed' : 'unchanged' - pbar.inc - report.save - end - pbar.finish + remove_index :reports, [:time, :node_id, :success] remove_column :reports, :success add_column :nodes, :status, :string - nodes = Node.all - pbar = ProgressBar.new("Migrating Nodes:", nodes.size, STDOUT) - nodes.each do |node| - node.status = node.last_report ? node.last_report.status : 'unchanged' - pbar.inc - node.save - end - pbar.finish remove_column :nodes, :success end -- 1.7.3.1 -- You received this message because you are subscribed to the Google Groups "Puppet Developers" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
