ruby on rails - Why do a add_index migration add the type string to a column if not called otherwise -


i have table existant t.integer :column_name.

if rails g migration add_index_to_table_name column_name:uniq existent column_name created new string type if dont call otherwise column_name:integer:uniq

why this? wouldnt easier add index :unique => true it?

the helper method intended handle adding or removing columns: api reference , rails guide.

you need first generate migration:

rails g migration add_index_to_table_name 

and edit contain appropriate commands:

class addindextotablename < activerecord:migration   def change     add_index :table_name, :column_name, unique: true   end end 

Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -