Single 'add_index' line in migration file produces multiple 'add_index' lines in my schema. (??)

24 views
Skip to first unread message

Bart Dority

unread,
Jul 14, 2015, 1:47:50 AM7/14/15
to rubyonra...@googlegroups.com
Hello,
I'm a newbie to Rails, and to this Group - just putting that out there.
Here's my question:

I have a migration file for a new table, and at the end of the file I added the line:
    add_index: :table_name, :name

I was trying to generate an index on a single column in my database.

But after running rake db:migrate ... I see 3 add_index lines added to my schema.rb file.

There's one for the :name column of the table, but rails seems to have also generated an add_index line for each column in the table.

Strange.  Anyone have ideas on this?
Thank you!


Colin Law

unread,
Jul 14, 2015, 3:35:31 AM7/14/15
to rubyonra...@googlegroups.com
If you leave out your add_index do all three disappear?
Which version of Rails are you running?

Colin

Elizabeth McGurty

unread,
Jul 14, 2015, 9:23:58 AM7/14/15
to rubyonra...@googlegroups.com
What a coincidence.  I just ran rails g model, and each field was duplicated.
Reply all
Reply to author
Forward
0 new messages