Sha256: 190e0b8006af04f67bded066764f8c28b19ea39cdc0d65f93167e574ebd15922

Contents?: true

Size: 1.43 KB

Versions: 191

Compression:

Stored size: 1.43 KB

Contents

class MoveContentSourceIdToContentFacets < ActiveRecord::Migration[4.2]
  def up
    add_column :katello_content_facets, :content_source_id, :integer
    add_index :katello_content_facets, :content_source_id
    add_foreign_key :katello_content_facets, :smart_proxies, :name => "katello_content_facets_content_source_id_fk", :column => "content_source_id"

    Host.find_each do |host|
      content_facet = host.content_facet
      if content_facet && (content_source_id = host.read_attribute(:content_source_id))
        content_facet.content_source_id = content_source_id
        content_facet.save!
      end
    end

    remove_foreign_key :hosts, :name => "hosts_content_source_id_fk"
    remove_index :hosts, :content_source_id
    remove_column :hosts, :content_source_id
  end

  def down
    add_column :hosts, :content_source_id, :integer
    add_index :hosts, :content_source_id
    add_foreign_key :hosts, :smart_proxies, :name => "hosts_content_source_id_fk", :column => "content_source_id"

    Host.find_each do |host|
      if host.content_facet
        host.content_source_id = host.content_facet.content_source_id
        if host.content_facet.content_source
          host.save!
        end
      end
    end

    remove_foreign_key :katello_content_facets, :name => "katello_content_facets_content_source_id_fk"
    remove_index :katello_content_facets, :content_source_id
    remove_column :katello_content_facets, :content_source_id
  end
end

Version data entries

191 entries across 191 versions & 1 rubygems

Version Path
katello-4.14.2 db/migrate/20161214151548_move_content_source_id_to_content_facets.rb
katello-4.15.0 db/migrate/20161214151548_move_content_source_id_to_content_facets.rb
katello-4.15.0.rc2 db/migrate/20161214151548_move_content_source_id_to_content_facets.rb
katello-4.15.0.rc1 db/migrate/20161214151548_move_content_source_id_to_content_facets.rb
katello-4.14.1 db/migrate/20161214151548_move_content_source_id_to_content_facets.rb
katello-4.14.0 db/migrate/20161214151548_move_content_source_id_to_content_facets.rb
katello-4.14.0.rc3 db/migrate/20161214151548_move_content_source_id_to_content_facets.rb
katello-4.14.0.rc2 db/migrate/20161214151548_move_content_source_id_to_content_facets.rb
katello-4.14.0.rc1.1 db/migrate/20161214151548_move_content_source_id_to_content_facets.rb
katello-4.14.0.rc1 db/migrate/20161214151548_move_content_source_id_to_content_facets.rb
katello-4.13.1 db/migrate/20161214151548_move_content_source_id_to_content_facets.rb
katello-4.13.0 db/migrate/20161214151548_move_content_source_id_to_content_facets.rb
katello-4.12.1 db/migrate/20161214151548_move_content_source_id_to_content_facets.rb
katello-4.13.0.rc1 db/migrate/20161214151548_move_content_source_id_to_content_facets.rb
katello-4.12.0 db/migrate/20161214151548_move_content_source_id_to_content_facets.rb
katello-4.12.0.rc3 db/migrate/20161214151548_move_content_source_id_to_content_facets.rb
katello-4.12.0.rc2 db/migrate/20161214151548_move_content_source_id_to_content_facets.rb
katello-4.12.0.rc1 db/migrate/20161214151548_move_content_source_id_to_content_facets.rb
katello-4.11.1 db/migrate/20161214151548_move_content_source_id_to_content_facets.rb
katello-4.11.0 db/migrate/20161214151548_move_content_source_id_to_content_facets.rb