Created
March 20, 2018 17:06
-
-
Save andreleoni/b2638bbb3e797f6cd5aa10d086efc814 to your computer and use it in GitHub Desktop.
list indexes of each table of database
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
| 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