Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save davidimoore/1bfb8c1bc5f3fda98e089389731a2348 to your computer and use it in GitHub Desktop.
Save davidimoore/1bfb8c1bc5f3fda98e089389731a2348 to your computer and use it in GitHub Desktop.
Get list of all indexes in rails console.
# rails console
ActiveRecord::Base.connection.tables.each do |table|
indexes = ActiveRecord::Base.connection.indexes(table)
if indexes.length > 0
puts "====> #{table} <===="
indexes.each do |index|
puts "----> #{index.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