Sha256: 2e88fe5e8cdf9439e7acb263a4626639ff19802f53eb151a0770ce6d65a536cb

Contents?: true

Size: 1.29 KB

Versions: 12

Compression:

Stored size: 1.29 KB

Contents

# This migration comes from knitkit (originally 20120127150506)
class AddPrimaryHostToWebsiteConfiguration
  
  def self.up
    unless ConfigurationItemType.find_by_internal_identifier('primary_host')
      website_setup_category = Category.find_by_internal_identifier('website_setup')
      configuration = ::Configuration.find_template('default_website_configuration')

      primary_host_config_item_type = ConfigurationItemType.create(
        :description => 'Primary Host',
        :internal_identifier => 'primary_host',
        :allow_user_defined_options => true
      )
      CategoryClassification.create(:category => website_setup_category, :classification => primary_host_config_item_type)
      configuration.configuration_item_types << primary_host_config_item_type
      configuration.save

      #update existing websites
      Website.all.each do |website|
        website_config = website.configurations.first
        if(website_config.internal_identifier == 'default_website_configuration')
          website_config.configuration_item_types << primary_host_config_item_type
          website_config.add_configuration_item(primary_host_config_item_type, website.hosts.first.host)
          website_config.save
        end
      end
    end
  end
  
  def self.down
    #remove data here
  end

end

Version data entries

12 entries across 12 versions & 3 rubygems

Version Path
knitkit-2.1.14 spec/dummy/db/data_migrations/20120127150506_add_primary_host_to_website_configuration.knitkit.rb
knitkit-2.1.13 spec/dummy/db/data_migrations/20120127150506_add_primary_host_to_website_configuration.knitkit.rb
knitkit-2.1.12 spec/dummy/db/data_migrations/20120127150506_add_primary_host_to_website_configuration.knitkit.rb
knitkit-2.1.9 spec/dummy/db/data_migrations/20120127150506_add_primary_host_to_website_configuration.knitkit.rb
knitkit-2.1.8 spec/dummy/db/data_migrations/20120127150506_add_primary_host_to_website_configuration.knitkit.rb
knitkit-2.1.7 spec/dummy/db/data_migrations/20120127150506_add_primary_host_to_website_configuration.knitkit.rb
knitkit-2.1.5 spec/dummy/db/data_migrations/20120127150506_add_primary_host_to_website_configuration.knitkit.rb
erp_search-3.1.1 spec/dummy/db/data_migrations/20120127150506_add_primary_host_to_website_configuration.knitkit.rb
knitkit-2.1.1 spec/dummy/db/data_migrations/20120127150506_add_primary_host_to_website_configuration.knitkit.rb
knitkit-2.1.0 spec/dummy/db/data_migrations/20120127150506_add_primary_host_to_website_configuration.knitkit.rb
erp_search-3.1.0 spec/dummy/db/data_migrations/20120127150506_add_primary_host_to_website_configuration.knitkit.rb
erp_invoicing-3.1.0 spec/dummy/db/data_migrations/20120127150506_add_primary_host_to_website_configuration.knitkit.rb