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

Invalid index recommendation for Doorkeeper Gem #105

Open ericraio opened 5 years ago

ericraio commented 5 years ago

I am getting this recommendation after installing the door keeper gem.

  1) DB Indexes sets the proper db indexes
     Failure/Error:
       expect(`rake db:find_indexes`).to match(/Yey, no missing indexes found!/), lambda {
                               "Missing db indexes were find run `rake db:find_indexes'" }

       Missing db indexes were find run `rake db:find_indexes'
       Diff:
       @@ -1,2 +1,11 @@
       -/Yey, no missing indexes found!/
       +* TIP: if you have a problem with the index name('index name too long'), you can
       +solve with the :name option. Something like :name => 'my_index'.
       +* run `rails g migration AddMissingIndexes` and add the following content:
       +
       +    class AddMissingIndexes < ActiveRecord::Migration
       +      def change
       +        add_index :oauth_access_tokens, [:doorkeeper/application_id, :doorkeeper/application_id]
       +      end
       +    end

Any idea how I can resolve this?

plentz commented 5 years ago

@ericraio are you trying to run lol_dba tests with a new gem?

ericraio commented 5 years ago

@ericraio are you trying to run lol_dba tests with a new gem?

No tests or anything like that, I just have a simple test that executes lol_dba

When running rake db:find_indexes, it's saying that I need to put an index for doorkeeper's table.

To reproduce,

add the gem lol_dba and doorkeeper + create doorkeeper tables

ericraio commented 5 years ago

@plentz

I'd like to highlight that lol_dba is failing because

the model class is Doorkeeper::Application and when you convert a nested model like this to underscore, it generates doorkeeper/application instead of doorkeeper_application

In addition to above,

add_index :oauth_access_tokens, [:doorkeeper/application_id, :doorkeeper/application_id]

This would not be the proper table because it is redefined internally.

sobrinho commented 5 years ago

I'm working on that on #81.