Sha256: 001fcdf14520a2517678e09b3ed8c5125bc725218348af14a86dda30a2345763

Contents?: true

Size: 1.19 KB

Versions: 34

Compression:

Stored size: 1.19 KB

Contents

class AddSomeIndexes < ActiveRecord::Migration[4.2]
  def up
    # puppetclasses
    add_index :puppetclasses, :name

    # turn off Foreign Key checks
    execute 'SET CONSTRAINTS ALL DEFERRED;' if ActiveRecord::Base.connection.adapter_name == 'PostgreSQL'

    add_foreign_key 'host_classes', 'hosts', name: 'host_classes_host_id_fk'
    add_foreign_key 'host_classes', 'puppetclasses', name: 'host_classes_puppetclass_id_fk'
    add_foreign_key 'operatingsystems_puppetclasses', 'operatingsystems', name: 'operatingsystems_puppetclasses_operatingsystem_id_fk'
    add_foreign_key 'operatingsystems_puppetclasses', 'puppetclasses', name: 'operatingsystems_puppetclasses_puppetclass_id_fk'
  end

  def down
    remove_foreign_key('host_classes', 'hosts') if foreign_key_exists?(:host_classes, :hosts)
    remove_foreign_key('host_classes', 'puppetclasses') if foreign_key_exists?(:host_classes, :puppetclasses)
    remove_foreign_key('operatingsystems_puppetclasses', 'operatingsystems') if foreign_key_exists?(:operatingsystems_puppetclasses, :operatingsystems)
    remove_foreign_key('operatingsystems_puppetclasses', 'puppetclasses') if foreign_key_exists?(:operatingsystems_puppetclasses, :puppetclasses)
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
foreman_puppet-2.0.7 db/migrate_foreman/20120824142048_add_some_indexes.foreman_puppet.rb
foreman_puppet-4.0.1 db/migrate_foreman/20120824142048_add_some_indexes.foreman_puppet.rb
foreman_puppet-4.0.0 db/migrate_foreman/20120824142048_add_some_indexes.foreman_puppet.rb
foreman_puppet-3.0.6 db/migrate_foreman/20120824142048_add_some_indexes.foreman_puppet.rb
foreman_puppet-2.0.6 db/migrate_foreman/20120824142048_add_some_indexes.foreman_puppet.rb
foreman_puppet-2.0.5 db/migrate_foreman/20120824142048_add_some_indexes.foreman_puppet.rb
foreman_puppet-3.0.5 db/migrate_foreman/20120824142048_add_some_indexes.foreman_puppet.rb
foreman_puppet-3.0.4 db/migrate_foreman/20120824142048_add_some_indexes.foreman_puppet.rb
foreman_puppet-2.0.4 db/migrate_foreman/20120824142048_add_some_indexes.foreman_puppet.rb
foreman_puppet-3.0.3 db/migrate_foreman/20120824142048_add_some_indexes.foreman_puppet.rb
foreman_puppet-3.0.2 db/migrate_foreman/20120824142048_add_some_indexes.foreman_puppet.rb
foreman_puppet-2.0.3 db/migrate_foreman/20120824142048_add_some_indexes.foreman_puppet.rb
foreman_puppet-3.0.1 db/migrate_foreman/20120824142048_add_some_indexes.foreman_puppet.rb
foreman_puppet-2.0.2 db/migrate_foreman/20120824142048_add_some_indexes.foreman_puppet.rb