Sha256: b93478bd5a6f45db9b189bd50334227fc0529dee4e4103a85dbf1a31b6da6b64

Contents?: true

Size: 677 Bytes

Versions: 33

Compression:

Stored size: 677 Bytes

Contents

class MoveHostDescriptionToHostComment < ActiveRecord::Migration
  class Host < ActiveRecord::Base
    self.table_name = "hosts"
  end

  def up
    Host.find_each do |host|
      new_comment = nil
      if host.comment.blank?
        new_comment = host.description
      else
        new_comment = [host.comment, host.description].join("\n") unless host.description.empty?
      end
      host.update_column(:comment, new_comment) if new_comment
    end

    remove_column :hosts, :description
  end

  def down
    add_column :hosts, :description, :text

    Host.find_each do |host|
      host.update_columns(:comment => nil, :description => host.comment)
    end
  end
end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
katello-3.4.5 db/migrate/20160426145517_move_host_description_to_host_comment.rb
katello-3.4.4 db/migrate/20160426145517_move_host_description_to_host_comment.rb
katello-3.4.2 db/migrate/20160426145517_move_host_description_to_host_comment.rb
katello-3.4.1 db/migrate/20160426145517_move_host_description_to_host_comment.rb
katello-3.4.0.2 db/migrate/20160426145517_move_host_description_to_host_comment.rb
katello-3.4.0.1 db/migrate/20160426145517_move_host_description_to_host_comment.rb
katello-3.3.2 db/migrate/20160426145517_move_host_description_to_host_comment.rb
katello-3.4.0 db/migrate/20160426145517_move_host_description_to_host_comment.rb
katello-3.4.0.rc2 db/migrate/20160426145517_move_host_description_to_host_comment.rb
katello-3.4.0.rc1 db/migrate/20160426145517_move_host_description_to_host_comment.rb
katello-3.3.1.1 db/migrate/20160426145517_move_host_description_to_host_comment.rb
katello-3.3.1 db/migrate/20160426145517_move_host_description_to_host_comment.rb
katello-3.3.0.1 db/migrate/20160426145517_move_host_description_to_host_comment.rb
katello-3.3.0 db/migrate/20160426145517_move_host_description_to_host_comment.rb
katello-3.3.0.rc2 db/migrate/20160426145517_move_host_description_to_host_comment.rb
katello-3.3.0.rc1.1 db/migrate/20160426145517_move_host_description_to_host_comment.rb
katello-3.3.0.rc1 db/migrate/20160426145517_move_host_description_to_host_comment.rb
katello-3.2.1.1 db/migrate/20160426145517_move_host_description_to_host_comment.rb
katello-3.2.1 db/migrate/20160426145517_move_host_description_to_host_comment.rb
katello-3.2.0 db/migrate/20160426145517_move_host_description_to_host_comment.rb