Skip to content

Instantly share code, notes, and snippets.

@andreleoni
Created March 20, 2018 17:06
Show Gist options
  • Select an option

  • Save andreleoni/b2638bbb3e797f6cd5aa10d086efc814 to your computer and use it in GitHub Desktop.

Select an option

Save andreleoni/b2638bbb3e797f6cd5aa10d086efc814 to your computer and use it in GitHub Desktop.
list indexes of each table of database
ActiveRecord::Base.connection.tables.each do |table|
indexes = ActiveRecord::Base.connection.indexes(table)
if indexes.length > 0
puts "====> #{table} <===="
indexes.each do |ind|
puts "----> #{ind.name}"
end
puts "====> #{table} <===="
2.times{ puts ''}
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment