Sha256: da3c96e3f1c8fce690498adb274c2c7057a66904fcc95735ba101848914ba5a2

Contents?: true

Size: 481 Bytes

Versions: 170

Compression:

Stored size: 481 Bytes

Contents

class RemoveDuplicatedIndexOnAllTables < ActiveRecord::Migration
  def self.up
    ActiveRecord::Base.connection.tables.each do |t|
      remove_index t.to_s, :id if ActiveRecord::Base.connection.indexes(t).collect {|c| c.columns}.include?("id")
    end
  end

  def self.down
    ActiveRecord::Base.connection.tables.each do |t|
      add_index t.to_s, :id, :integer => true unless ActiveRecord::Base.connection.indexes(t).collect {|c| c.columns}.include?("id")
    end
  end
end

Version data entries

170 entries across 170 versions & 5 rubygems

Version Path
puppet-2.6.9 lib/puppet/rails/database/002_remove_duplicated_index_on_all_tables.rb
puppet-2.6.8 lib/puppet/rails/database/002_remove_duplicated_index_on_all_tables.rb
puppet-2.6.7 lib/puppet/rails/database/002_remove_duplicated_index_on_all_tables.rb
puppet-2.6.6 lib/puppet/rails/database/002_remove_duplicated_index_on_all_tables.rb
puppet-2.6.5 lib/puppet/rails/database/002_remove_duplicated_index_on_all_tables.rb
puppet-2.6.4 lib/puppet/rails/database/002_remove_duplicated_index_on_all_tables.rb
puppet-2.6.3 lib/puppet/rails/database/002_remove_duplicated_index_on_all_tables.rb
puppet-2.6.2 lib/puppet/rails/database/002_remove_duplicated_index_on_all_tables.rb
puppet-2.6.1 lib/puppet/rails/database/002_remove_duplicated_index_on_all_tables.rb
puppet-2.6.0 lib/puppet/rails/database/002_remove_duplicated_index_on_all_tables.rb