eladmeidar / rails_indexes

A rake task to track down missing database indexes. does not assume that all foreign keys end with the convention of _id.
http://blog.eizesus.com/2009/9/find-where-to-index-your-tables-on-a-rails-app/
MIT License
490 stars 35 forks source link

Should be less strict with class names #18

Open zubin opened 14 years ago

zubin commented 14 years ago

eg when using aasm gem:

# vendor/gems/aasm-2.1.5/lib/aasm.rb
module AASM
end

~/g2(master) > rake db:index_migration -t
(in /Users/zubin/ww/g2)
** Invoke db:index_migration (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:index_migration
rake aborted!
Expected /Users/zubin/ww/g2/vendor/gems/aasm-2.1.5/lib/aasm.rb to define Aasm

Also happens with AR models, eg:

# app/models/mad_mimi_api.rb
class MadMimiAPI
  ...
end

~/g2(master) > rake db:index_migration -t
(in /Users/zubin/ww/g2)
** Invoke db:index_migration (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:index_migration
rake aborted!
Expected /Users/zubin/ww/g2/app/models/mad_mimi_api.rb to define MadMimiApi
/Users/zubin/ww/g2/vendor/rails/activesupport/lib/active_support/dependencies.rb:426:in `load_missing_constant'
/Users/zubin/ww/g2/vendor/rails/activesupport/lib/active_support/dependencies.rb:80:in `const_missing'
/Users/zubin/ww/g2/vendor/rails/activesupport/lib/active_support/dependencies.rb:92:in `const_missing'
/Users/zubin/ww/g2/vendor/plugins/rails_indexes/tasks/../lib/indexer.rb:19:in `const_get'
/Users/zubin/ww/g2/vendor/plugins/rails_indexes/tasks/../lib/indexer.rb:19:in `check_for_indexes'
/Users/zubin/ww/g2/vendor/rails/activesupport/lib/active_support/dependencies.rb:443:in `inject'
/Users/zubin/ww/g2/vendor/plugins/rails_indexes/tasks/../lib/indexer.rb:19:in `each'
/Users/zubin/ww/g2/vendor/plugins/rails_indexes/tasks/../lib/indexer.rb:19:in `inject'
/Users/zubin/ww/g2/vendor/plugins/rails_indexes/tasks/../lib/indexer.rb:19:in `check_for_indexes'
/Users/zubin/ww/g2/vendor/plugins/rails_indexes/tasks/../lib/indexer.rb:16:in `each'
/Users/zubin/ww/g2/vendor/plugins/rails_indexes/tasks/../lib/indexer.rb:16:in `check_for_indexes'
/Users/zubin/ww/g2/vendor/plugins/rails_indexes/tasks/../lib/indexer.rb:222:in `simple_migration'
/Users/zubin/ww/g2/vendor/plugins/rails_indexes/tasks/indexer.rake:10
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `call'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `execute'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `each'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `execute'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:597:in `invoke_with_call_chain'
/opt/local/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:583:in `invoke'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2051:in `invoke_task'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `each'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2023:in `top_level'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2001:in `run'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:1998:in `run'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/bin/rake:31
/opt/local/bin/rake:19:in `load'
/opt/local/bin/rake:19
plentz commented 11 years ago

I think I've fixed this problem @ lol_dba