Created
November 21, 2018 21:10
-
-
Save oma/2a8480cac9898f8fbb38d3f83ee5d550 to your computer and use it in GitHub Desktop.
show database indexes in rails
This file contains 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
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