Created
September 10, 2018 12:36
-
-
Save davygora/943e9fbaf736a6796a2d7a98a57ed4a0 to your computer and use it in GitHub Desktop.
Get list of all indexes in rails console.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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
Very helpful, thanks! ๐