Skip to content

Instantly share code, notes, and snippets.

@davygora
Created September 10, 2018 12:36
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save davygora/943e9fbaf736a6796a2d7a98a57ed4a0 to your computer and use it in GitHub Desktop.
Save davygora/943e9fbaf736a6796a2d7a98a57ed4a0 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
@josef-krabath
Copy link

Very helpful, thanks! 👍

@mohammed-bamatraf
Copy link

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment