Is there a gem or plugin like https://github.com/eladmeidar/rails_indexes that works for rails3?
There's a fork of rails_indexes that has been updated to work with Rails 3 and Ruby 1.9
https://github.com/plentz/lol_dba
You can paste following code in your console to know the missing foreign key indexes. This, however, is not as capable of the plugin that you refer to. It only searches for rails style foreign keys that have an _id
at the end of their column name.
c = ActiveRecord::Base.connection
c.tables.collect do |t|
columns = c.columns(t).collect(&:name).select {|x| x.ends_with?("_id") || x.ends_with?("_type")}
indexed_columns = c.indexes(t).collect(&:columns).flatten.uniq
unindexed = columns - indexed_columns
unless unindexed.empty?
puts "#{t}: #{unindexed.join(", ")}"
end
end
Source
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With