Sha256: 29397c507ed6e36291c0df3921aabb002835ea5d42070048cc060287161760ec

Contents?: true

Size: 644 Bytes

Versions: 88

Compression:

Stored size: 644 Bytes

Contents

class UpdateProductsAddOrganization < ActiveRecord::Migration[4.2]
  class FakeProduct < ApplicationRecord
    self.table_name = 'katello_products'
    belongs_to :provider
    self.inheritance_column = nil
  end

  def up
    add_column :katello_products, :organization_id, :integer, :null => true

    FakeProduct.all.each do |product|
      product.organization_id = product.provider.organization_id
      product.save!
    end

    change_column :katello_products, :organization_id, :integer, :null => false
    add_index :katello_products, :organization_id
  end

  def down
    remove_column :katello_products, :organization_id
  end
end

Version data entries

88 entries across 88 versions & 1 rubygems

Version Path
katello-4.1.2 db/migrate/20140422000001_update_products_add_organization.rb
katello-4.1.1 db/migrate/20140422000001_update_products_add_organization.rb
katello-4.1.0 db/migrate/20140422000001_update_products_add_organization.rb
katello-4.1.0.rc2.2 db/migrate/20140422000001_update_products_add_organization.rb
katello-4.1.0.rc2.1 db/migrate/20140422000001_update_products_add_organization.rb
katello-4.1.0.rc2 db/migrate/20140422000001_update_products_add_organization.rb
katello-4.1.0.rc1.1 db/migrate/20140422000001_update_products_add_organization.rb
katello-4.1.0.rc1 db/migrate/20140422000001_update_products_add_organization.rb