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