mysql - Avoid default activerecord primary index creation -


i trying workout how advise/tell activerecord not create it's primary index default.

anyone know how can achieve ?

class createhouse < activerecord::migration  def change     create_table :houses |table|       table.string :name, :null => false, :unique => true       table.integer :number, :null => false, :unique => true       table.string :category, :null => false       table.timestamps(:null => false)     end     add_index :houses, [:category, :number], :unique => true   end end 

thanks

you can add id: false create_table definition. try following:

class createhouse < activerecord::migration  def change     create_table :houses, id: false |table|       table.string :name, :null => false, :unique => true       table.integer :number, :null => false, :unique => true       table.string :category, :null => false       table.timestamps(:null => false)     end     add_index :houses, [:category, :number], :unique => true   end end 

update:

updated create_table , add_index block use :houses symbol , not :stores suggested kengimel in edit request (which apparently got rejected!).


Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -