Sha256: e034a73cbf050434f41e356d52682ea5ecfbc9bde188a7b8520fc496ee64fb23

Contents?: true

Size: 1.39 KB

Versions: 22

Compression:

Stored size: 1.39 KB

Contents

class MoveContentSourceIdToContentFacets < ActiveRecord::Migration
  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 && host.content_source_id
        content_facet.content_source_id = host.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

22 entries across 22 versions & 1 rubygems

Version Path
katello-3.5.2 db/migrate/20161214151548_move_content_source_id_to_content_facets.rb
katello-3.5.1.1 db/migrate/20161214151548_move_content_source_id_to_content_facets.rb
katello-3.5.1 db/migrate/20161214151548_move_content_source_id_to_content_facets.rb
katello-3.5.0.1 db/migrate/20161214151548_move_content_source_id_to_content_facets.rb
katello-3.5.0 db/migrate/20161214151548_move_content_source_id_to_content_facets.rb
katello-3.5.0.rc2 db/migrate/20161214151548_move_content_source_id_to_content_facets.rb
katello-3.5.0.rc1 db/migrate/20161214151548_move_content_source_id_to_content_facets.rb
katello-3.4.5 db/migrate/20161214151548_move_content_source_id_to_content_facets.rb
katello-3.4.4 db/migrate/20161214151548_move_content_source_id_to_content_facets.rb
katello-3.4.2 db/migrate/20161214151548_move_content_source_id_to_content_facets.rb
katello-3.4.1 db/migrate/20161214151548_move_content_source_id_to_content_facets.rb
katello-3.4.0.2 db/migrate/20161214151548_move_content_source_id_to_content_facets.rb
katello-3.4.0.1 db/migrate/20161214151548_move_content_source_id_to_content_facets.rb
katello-3.3.2 db/migrate/20161214151548_move_content_source_id_to_content_facets.rb
katello-3.4.0 db/migrate/20161214151548_move_content_source_id_to_content_facets.rb
katello-3.4.0.rc2 db/migrate/20161214151548_move_content_source_id_to_content_facets.rb
katello-3.4.0.rc1 db/migrate/20161214151548_move_content_source_id_to_content_facets.rb
katello-3.3.1.1 db/migrate/20161214151548_move_content_source_id_to_content_facets.rb
katello-3.3.1 db/migrate/20161214151548_move_content_source_id_to_content_facets.rb
katello-3.3.0.1 db/migrate/20161214151548_move_content_source_id_to_content_facets.rb