Sha256: 97b178d6978f39421327ffd03ba83393342d072b0962212f1ded5b8ec1588e16

Contents?: true

Size: 695 Bytes

Versions: 47

Compression:

Stored size: 695 Bytes

Contents

class FixLookupKeyAuditableType < ActiveRecord::Migration[4.2]
  def up
    Audit.reorder(nil).joins('JOIN lookup_keys ON lookup_keys.id = audits.auditable_id')
         .where(auditable_type: 'LookupKey', lookup_keys: { type: 'VariableLookupKey' })
         .update_all(auditable_type: 'VariableLookupKey')

    Audit.reorder(nil).joins('JOIN lookup_keys ON lookup_keys.id = audits.auditable_id')
         .where(auditable_type: 'LookupKey', lookup_keys: { type: 'PuppetclassLookupKey' })
         .update_all(auditable_type: 'PuppetclassLookupKey')
  end

  def down
    Audit.where(auditable_type: %w[PuppetclassLookupKey VariableLookupKey]).update_all(auditable_type: 'LookupKey')
  end
end

Version data entries

47 entries across 47 versions & 1 rubygems

Version Path
foreman_puppet-8.0.0 db/migrate_foreman/20170109115157_fix_lookup_key_auditable_type.foreman_puppet.rb
foreman_puppet-6.4.0 db/migrate_foreman/20170109115157_fix_lookup_key_auditable_type.foreman_puppet.rb
foreman_puppet-7.0.0 db/migrate_foreman/20170109115157_fix_lookup_key_auditable_type.foreman_puppet.rb
foreman_puppet-6.3.0 db/migrate_foreman/20170109115157_fix_lookup_key_auditable_type.foreman_puppet.rb
foreman_puppet-6.2.0 db/migrate_foreman/20170109115157_fix_lookup_key_auditable_type.foreman_puppet.rb
foreman_puppet-6.1.1 db/migrate_foreman/20170109115157_fix_lookup_key_auditable_type.foreman_puppet.rb
foreman_puppet-5.1.3 db/migrate_foreman/20170109115157_fix_lookup_key_auditable_type.foreman_puppet.rb
foreman_puppet-6.1.0 db/migrate_foreman/20170109115157_fix_lookup_key_auditable_type.foreman_puppet.rb
foreman_puppet-6.0.1 db/migrate_foreman/20170109115157_fix_lookup_key_auditable_type.foreman_puppet.rb
foreman_puppet-6.0.0 db/migrate_foreman/20170109115157_fix_lookup_key_auditable_type.foreman_puppet.rb
foreman_puppet-5.1.2 db/migrate_foreman/20170109115157_fix_lookup_key_auditable_type.foreman_puppet.rb
foreman_puppet-4.1.1 db/migrate_foreman/20170109115157_fix_lookup_key_auditable_type.foreman_puppet.rb
foreman_puppet-5.1.1 db/migrate_foreman/20170109115157_fix_lookup_key_auditable_type.foreman_puppet.rb
foreman_puppet-5.1.0 db/migrate_foreman/20170109115157_fix_lookup_key_auditable_type.foreman_puppet.rb
foreman_puppet-4.1.0 db/migrate_foreman/20170109115157_fix_lookup_key_auditable_type.foreman_puppet.rb
foreman_puppet-4.0.4 db/migrate_foreman/20170109115157_fix_lookup_key_auditable_type.foreman_puppet.rb
foreman_puppet-5.0.0 db/migrate_foreman/20170109115157_fix_lookup_key_auditable_type.foreman_puppet.rb
foreman_puppet-4.0.3 db/migrate_foreman/20170109115157_fix_lookup_key_auditable_type.foreman_puppet.rb
foreman_puppet-4.0.2 db/migrate_foreman/20170109115157_fix_lookup_key_auditable_type.foreman_puppet.rb
foreman_puppet-3.0.7 db/migrate_foreman/20170109115157_fix_lookup_key_auditable_type.foreman_puppet.rb