Skip to content

Instantly share code, notes, and snippets.

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