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-1.0.1 db/migrate_foreman/20170109115157_fix_lookup_key_auditable_type.rb
foreman_puppet-1.0.0 db/migrate_foreman/20170109115157_fix_lookup_key_auditable_type.rb
foreman_puppet-1.0.0.rc.2 db/migrate_foreman/20170109115157_fix_lookup_key_auditable_type.rb
foreman_puppet-1.0.0.rc.1 db/migrate_foreman/20170109115157_fix_lookup_key_auditable_type.rb
foreman_puppet-0.1.0 db/migrate_foreman/20170109115157_fix_lookup_key_auditable_type.rb
foreman_puppet-0.0.2 db/migrate_foreman/20170109115157_fix_lookup_key_auditable_type.rb
foreman_puppet-0.0.1 db/migrate_foreman/20170109115157_fix_lookup_key_auditable_type.rb