Sha256: 041516c93c86aa5cfac3da0dd9dc2ee206f61503cef3e772c5c6c38313d5ea1d

Contents?: true

Size: 681 Bytes

Versions: 200

Compression:

Stored size: 681 Bytes

Contents

class MoveHostDescriptionToHostComment < ActiveRecord::Migration[4.2]
  class Host < ApplicationRecord
    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

200 entries across 200 versions & 1 rubygems

Version Path
katello-4.16.0 db/migrate/20160426145517_move_host_description_to_host_comment.rb
katello-4.15.1 db/migrate/20160426145517_move_host_description_to_host_comment.rb
katello-4.16.0.rc2 db/migrate/20160426145517_move_host_description_to_host_comment.rb
katello-4.16.0.rc1 db/migrate/20160426145517_move_host_description_to_host_comment.rb
katello-4.14.3 db/migrate/20160426145517_move_host_description_to_host_comment.rb
katello-4.14.2 db/migrate/20160426145517_move_host_description_to_host_comment.rb
katello-4.15.0 db/migrate/20160426145517_move_host_description_to_host_comment.rb
katello-4.15.0.rc2 db/migrate/20160426145517_move_host_description_to_host_comment.rb
katello-4.15.0.rc1 db/migrate/20160426145517_move_host_description_to_host_comment.rb
katello-4.14.1 db/migrate/20160426145517_move_host_description_to_host_comment.rb
katello-4.14.0 db/migrate/20160426145517_move_host_description_to_host_comment.rb
katello-4.14.0.rc3 db/migrate/20160426145517_move_host_description_to_host_comment.rb
katello-4.14.0.rc2 db/migrate/20160426145517_move_host_description_to_host_comment.rb
katello-4.14.0.rc1.1 db/migrate/20160426145517_move_host_description_to_host_comment.rb
katello-4.14.0.rc1 db/migrate/20160426145517_move_host_description_to_host_comment.rb
katello-4.13.1 db/migrate/20160426145517_move_host_description_to_host_comment.rb
katello-4.13.0 db/migrate/20160426145517_move_host_description_to_host_comment.rb
katello-4.12.1 db/migrate/20160426145517_move_host_description_to_host_comment.rb
katello-4.13.0.rc1 db/migrate/20160426145517_move_host_description_to_host_comment.rb
katello-4.12.0 db/migrate/20160426145517_move_host_description_to_host_comment.rb