Sha256: 2e534604e4308e1060c2f517d62f1c8ced46cf4fd39088c303b6fc9faf6f8adc

Contents?: true

Size: 622 Bytes

Versions: 14

Compression:

Stored size: 622 Bytes

Contents

class MigrateEnvironmentIgnoreType < ActiveRecord::Migration[6.0]
  def up
    taxonomies = Taxonomy.unscoped.where("ignore_types LIKE '%Environment%'")
    environment_ids = ForemanPuppet::Environment.unscoped.pluck(:id)

    taxonomies.each do |tax|
      new_types = tax.ignore_types.reject { |type| type == 'Environment' }
      tax.update_columns(ignore_types: new_types)
      taxable_rows = environment_ids.map do |env_id|
        { taxable_id: env_id, taxable_type: 'ForemanPuppet::Environment', taxonomy_id: tax.id }
      end
      TaxableTaxonomy.insert_all(taxable_rows) if taxable_rows.any?
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
foreman_puppet-4.0.2 db/migrate/20220208135305_migrate_environment_ignore_type.foreman_puppet.rb
foreman_puppet-3.0.7 db/migrate/20220208135305_migrate_environment_ignore_type.foreman_puppet.rb
foreman_puppet-2.0.7 db/migrate/20220208135305_migrate_environment_ignore_type.foreman_puppet.rb
foreman_puppet-4.0.1 db/migrate/20220208135305_migrate_environment_ignore_type.foreman_puppet.rb
foreman_puppet-4.0.0 db/migrate/20220208135305_migrate_environment_ignore_type.foreman_puppet.rb
foreman_puppet-3.0.6 db/migrate/20220208135305_migrate_environment_ignore_type.foreman_puppet.rb
foreman_puppet-2.0.6 db/migrate/20220208135305_migrate_environment_ignore_type.foreman_puppet.rb
foreman_puppet-2.0.5 db/migrate/20220208135305_migrate_environment_ignore_type.foreman_puppet.rb
foreman_puppet-3.0.5 db/migrate/20220208135305_migrate_environment_ignore_type.foreman_puppet.rb
foreman_puppet-3.0.4 db/migrate/20220208135305_migrate_environment_ignore_type.foreman_puppet.rb
foreman_puppet-2.0.4 db/migrate/20220208135305_migrate_environment_ignore_type.foreman_puppet.rb
foreman_puppet-3.0.3 db/migrate/20220208135305_migrate_environment_ignore_type.foreman_puppet.rb
foreman_puppet-3.0.2 db/migrate/20220208135305_migrate_environment_ignore_type.foreman_puppet.rb
foreman_puppet-2.0.3 db/migrate/20220208135305_migrate_environment_ignore_type.foreman_puppet.rb