plentz / lol_dba

lol_dba is a small package of rake tasks that scan your application models and displays a list of columns that probably should be indexed. Also, it can generate .sql migration scripts.
1.59k stars 69 forks source link

has_many: indexes being created for inexistent columns #76

Open plentz opened 8 years ago

plentz commented 8 years ago

This is being fixed @ has_many_fix branch. This is the failing case that should be fixed https://github.com/plentz/lol_dba/commit/bf9c4eb7124d3f998d6cf65ffb3165a2068b4335#diff-d90d1bc62234f746df962016d75e56c8R58

tuykin commented 6 years ago

foreign_key and foreign_type modifiers are not counted.

Here's my case:

# content.rb
class Content < ApplicationRecord
  belongs_to :material, polymorphic: true, foreign_key: :id_content, foreign_type: :type_content
end

Index suggested to add:

add_index :contents, [:material_id, :material_type]

I don't know, if I should create separate issue for that