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-parse-0.1.2 lib/vendor/puppet/rails/database/002_remove_duplicated_index_on_all_tables.rb
puppet-parse-0.1.1 lib/vendor/puppet/rails/database/002_remove_duplicated_index_on_all_tables.rb
puppet-3.7.3 lib/puppet/rails/database/002_remove_duplicated_index_on_all_tables.rb
puppet-3.7.3-x86-mingw32 lib/puppet/rails/database/002_remove_duplicated_index_on_all_tables.rb
puppet-3.7.3-x64-mingw32 lib/puppet/rails/database/002_remove_duplicated_index_on_all_tables.rb
puppet-3.7.2 lib/puppet/rails/database/002_remove_duplicated_index_on_all_tables.rb
puppet-3.7.2-x86-mingw32 lib/puppet/rails/database/002_remove_duplicated_index_on_all_tables.rb
puppet-3.7.2-x64-mingw32 lib/puppet/rails/database/002_remove_duplicated_index_on_all_tables.rb
puppet-3.7.1 lib/puppet/rails/database/002_remove_duplicated_index_on_all_tables.rb
puppet-3.7.1-x86-mingw32 lib/puppet/rails/database/002_remove_duplicated_index_on_all_tables.rb
puppet-3.7.1-x64-mingw32 lib/puppet/rails/database/002_remove_duplicated_index_on_all_tables.rb
puppet-3.7.0 lib/puppet/rails/database/002_remove_duplicated_index_on_all_tables.rb
puppet-3.7.0-x86-mingw32 lib/puppet/rails/database/002_remove_duplicated_index_on_all_tables.rb
puppet-3.7.0-x64-mingw32 lib/puppet/rails/database/002_remove_duplicated_index_on_all_tables.rb
puppet-2.7.26 lib/puppet/rails/database/002_remove_duplicated_index_on_all_tables.rb
puppet-3.6.2 lib/puppet/rails/database/002_remove_duplicated_index_on_all_tables.rb
puppet-3.6.2-x86-mingw32 lib/puppet/rails/database/002_remove_duplicated_index_on_all_tables.rb
puppet-3.6.1 lib/puppet/rails/database/002_remove_duplicated_index_on_all_tables.rb
puppet-3.6.1-x86-mingw32 lib/puppet/rails/database/002_remove_duplicated_index_on_all_tables.rb
puppet-3.6.0 lib/puppet/rails/database/002_remove_duplicated_index_on_all_tables.rb