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

Polymorphic association generates migration with syntax error. #64

Closed joshuapinter closed 8 years ago

joshuapinter commented 9 years ago

Hey there.

Using v 2.0.1 out of master. I have an Attachment model that is polymorphic with the following definition in the model:

class Attachment < ActiveRecord::Base
  belongs_to :attachable,  polymorphic: true
end

Using rake db:find_indexes it generates the following migration suggestion:

class AddMissingIndexes < ActiveRecord::Migration
  def change
    add_index :attachments, [:["attachable_id", "attachable_type"]]
  end
end

And when running rake db:migrate I get:

syntax error, unexpected '[', expecting tSTRING_CONTENT or tSTRING_DBEG or tSTRING_DVAR or tSTRING_END
    add_index :attachments, [:["attachable_id", "attachable_type"]]

I can look into it if you want to point me in the right direction...

Thanks!

Vorob-Astronaut commented 9 years ago

have the same error

plentz commented 8 years ago

@joshuapinter @Vorob-Astronaut hey guys. I've just released 2.0.2 with a fix for this. Can you test it, please? Feedback appreciated :)

plentz commented 8 years ago

(duplicates #62, btw)