Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hernan/4e207289d1e659a8119e69a70c202020 to your computer and use it in GitHub Desktop.
Save hernan/4e207289d1e659a8119e69a70c202020 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