Created
August 14, 2020 14:56
-
-
Save eaconde/434ac636e97b67cc8cc148029d43b678 to your computer and use it in GitHub Desktop.
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
# Establish connection | |
conn = ActiveRecord::Base.connection | |
# Cycle tables | |
conn.tables.collect do |t| | |
# Gather columns | |
columns = c.columns(t).collect(&:name).select {|x| x.ends_with?("_id" || x.ends_with("_type"))} | |
# Collect all indexed | |
indexed_columns = c.indexes(t).collect(&:columns).flatten.uniq | |
# Identify unindexed | |
unindexed = columns - indexed_columns | |
# Display | |
unless unindexed.empty? | |
puts "#{t}: #{unindexed.join(", ")}" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment