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

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -